forked from deftlabs/mongodb-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
189 lines (143 loc) · 7.06 KB
/
Copy pathbuild.xml
File metadata and controls
189 lines (143 loc) · 7.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<?xml version="1.0"?>
<!--
Copyright 2011, Deft Labs.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="mongo-java-sharding-example" default="usage" basedir="./" xmlns:aspectj="antlib:org.aspectj">
<!-- ******************************************************************* -->
<!-- Set the base attributes. -->
<!-- ******************************************************************* -->
<property name="dir.build" value="build"/>
<property name="dir.build.java" value="${dir.build}/java/classes"/>
<property name="dir.src" value="src"/>
<property name="dir.src.java" value="src/main"/>
<property name="dir.lib" value="lib"/>
<property file="build.properties" prefix="build.conf"/>
<property environment="env"/>
<path id="classpath.all"><fileset dir="${dir.lib}"><include name="*.jar"/></fileset></path>
<path id="classpath.cp"><pathelement location="${dir.build.java}"/></path>
<!-- ******************************************************************* -->
<!-- Remove the build directory. -->
<!-- ******************************************************************* -->
<target name="clean"><delete dir="${dir.build}"/></target>
<!-- ******************************************************************* -->
<!-- Compile the java classes. -->
<!-- ******************************************************************* -->
<target name="compile">
<mkdir dir="${dir.build.java}"/>
<javac destdir="${dir.build.java}"
target="${build.conf.javac.source}"
debug="true" encoding="UTF-8"
classpathref="classpath.cp"
source="${build.conf.javac.source}"
includeantruntime="false"
debuglevel="lines,vars,source">
<src path="${dir.src.java}"/>
<compilerarg value="-Xlint:all,-fallthrough"/>
<classpath refid="classpath.all"/>
</javac>
</target>
<!-- ******************************************************************* -->
<!-- Run the examples. Mongo must be running to work. -->
<!-- ******************************************************************* -->
<target name="run" depends="compile">
<junit fork="yes" haltonfailure="true">
<jvmarg value="-Duser.timezone=GMT"/>
<jvmarg value="-Dfile.encoding=UTF-8"/>
<jvmarg value="-DsocksProxyHost"/>
<jvmarg value="-DsocksProxtPort"/>
<jvmarg value="-Dhttps.proxyHost"/>
<jvmarg value="-Dhttp.proxyHost"/>
<classpath refid="classpath.all"/>
<classpath><pathelement path="${dir.build.java}"/></classpath>
<formatter type="brief" usefile="false"/>
<batchtest todir=".">
<fileset dir="${dir.build.java}">
<include name="**/*Example.class"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- ******************************************************************* -->
<!-- Run the first mongo shard server. -->
<!-- ******************************************************************* -->
<target name="mongo-shard-0">
<antcall target="mongo-shard">
<param name="mongo.port" value="27018"/>
<param name="mongo.dir.db" value="${dir.build}/data/shard0"/>
</antcall>
</target>
<!-- ******************************************************************* -->
<!-- Run the second mongo shard server. -->
<!-- ******************************************************************* -->
<target name="mongo-shard-1">
<antcall target="mongo-shard">
<param name="mongo.port" value="27019"/>
<param name="mongo.dir.db" value="${dir.build}/data/shard1"/>
</antcall>
</target>
<!-- ******************************************************************* -->
<!-- Run a mongo shard server (expects params). -->
<!-- ******************************************************************* -->
<target name="mongo-shard">
<mkdir dir="${mongo.dir.db}"/>
<exec executable="mongod">
<arg value="--shardsvr"/>
<arg value="--rest"/>
<arg value="--port"/>
<arg value="${mongo.port}"/>
<arg value="--dbpath"/>
<arg value="${mongo.dir.db}"/>
</exec>
</target>
<!-- ******************************************************************* -->
<!-- Run a mongo config server. -->
<!-- ******************************************************************* -->
<target name="mongo-config">
<mkdir dir="${dir.build}/data/config"/>
<exec executable="mongod">
<arg value="--configsvr"/>
<arg value="--rest"/>
<arg value="--port"/>
<arg value="27020"/>
<arg value="--dbpath"/>
<arg value="${dir.build}/data/config"/>
</exec>
</target>
<!-- ******************************************************************* -->
<!-- Run a mongos server. -->
<!-- ******************************************************************* -->
<target name="mongos">
<exec executable="mongos">
<arg value="--configdb"/>
<arg value="localhost:27020"/>
<arg value="--chunkSize"/>
<arg value="1"/>
</exec>
</target>
<!-- ******************************************************************* -->
<!-- Describe the build file usage. -->
<!-- ******************************************************************* -->
<target name="usage">
<echo>
----------------------------------------
- Compile the Java files ......................... compile
- Clean the source tree .......................... clean (deletes Mongo db files too)
- Run the first Mongo shard server ............... mongo-shard-0
- Run the second Mongo shard server .............. mongo-shard-1
- Run the Mongo config server .................... mongo-config
- Run the mongos server ......................... mongos
- Run the examples ............................... run
----------------------------------------
</echo>
</target>
<!-- ******************************************************************* -->
</project>