Revision 6966
Added by ben leinfelder almost 13 years ago
src/edu/ucsb/nceas/metacat/admin/upgrade/GenerateSystemMetadata.java | ||
---|---|---|
30 | 30 |
import java.util.List; |
31 | 31 |
import java.util.concurrent.ExecutorService; |
32 | 32 |
import java.util.concurrent.Executors; |
33 |
import java.util.concurrent.TimeUnit; |
|
33 | 34 |
|
34 | 35 |
import org.apache.commons.logging.Log; |
35 | 36 |
import org.apache.commons.logging.LogFactory; |
36 | 37 |
|
38 |
import com.hazelcast.core.Hazelcast; |
|
39 |
|
|
37 | 40 |
import edu.ucsb.nceas.metacat.DBUtil; |
38 | 41 |
import edu.ucsb.nceas.metacat.admin.AdminException; |
39 | 42 |
import edu.ucsb.nceas.metacat.dataone.SystemMetadataFactory; |
43 |
import edu.ucsb.nceas.metacat.dataone.hazelcast.HazelcastService; |
|
40 | 44 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
41 | 45 |
import edu.ucsb.nceas.utilities.SortedProperties; |
42 | 46 |
|
... | ... | |
106 | 110 |
|
107 | 111 |
ExecutorService executor = Executors.newFixedThreadPool(nThreads); |
108 | 112 |
|
113 |
// init HZ |
|
114 |
log.debug("STARTING HAZELCAST"); |
|
115 |
HazelcastService.getInstance(); |
|
116 |
|
|
109 | 117 |
// chunk into groups |
110 | 118 |
int fromIndex = 0; |
111 | 119 |
int toIndex = 0; |
... | ... | |
154 | 162 |
prefix = previousId.substring(0, previousId.lastIndexOf(".")); |
155 | 163 |
|
156 | 164 |
} |
157 |
|
|
165 |
|
|
166 |
log.debug("DONE LAUNCHING THREADS"); |
|
167 |
|
|
158 | 168 |
// wait for executor to finish |
159 | 169 |
executor.shutdown(); |
160 | 170 |
|
171 |
// wait a long time |
|
172 |
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.HOURS); |
|
173 |
|
|
174 |
log.debug("DONE WAITING FOR THREAD"); |
|
175 |
|
|
176 |
log.debug("SHUTTING DOWN HAZELCAST"); |
|
177 |
HazelcastService.getInstance().stop(); |
|
178 |
log.debug("DONE SHUTTING DOWN HAZELCAST"); |
|
179 |
|
|
180 |
|
|
161 | 181 |
} catch (Exception e) { |
162 | 182 |
String msg = "Problem generating missing system metadata: " + e.getMessage(); |
163 | 183 |
log.error(msg, e); |
build.xml | ||
---|---|---|
280 | 280 |
value="./test/edu/ucsb/nceas/metacattest" /> |
281 | 281 |
<property name="junitnettestsdir" |
282 | 282 |
value="./test/edu/ucsb/nceas/metacatnettest" /> |
283 |
<property name="classtorun" value="edu.ucsb.nceas.metacat.admin.upgrade.GenerateSystemMetadata" /> |
|
283 | 284 |
<property name="build.dir" value="./build" /> |
284 | 285 |
<property name="build.src" value="${build.dir}/src" /> |
285 | 286 |
<property name="build.dest" value="${build.dir}/classes" /> |
... | ... | |
1080 | 1081 |
|
1081 | 1082 |
</target> |
1082 | 1083 |
|
1083 |
<target name="test" depends="testprep" |
|
1084 |
description="Uses the ant junit task to run all JUnit tests"> |
|
1085 |
|
|
1086 |
<!-- use the ant "junit" task to run JUnit tests. --> |
|
1087 |
<junit printsummary="yes" haltonfailure="no" fork="yes" |
|
1088 |
haltonerror="no"> |
|
1084 |
<target name="runoneclass" depends="testprep" |
|
1085 |
description="Uses the ant to run a class"> |
|
1086 |
|
|
1087 |
<java classname="${classtorun}" fork="true"> |
|
1089 | 1088 |
<jvmarg value="-Dfile.encoding=UTF-8"/> |
1090 | 1089 |
<classpath> |
1091 | 1090 |
<path refid="test.classpath" /> |
... | ... | |
1096 | 1095 |
<include name="${name}-junittests.jar" /> |
1097 | 1096 |
</fileset> |
1098 | 1097 |
</classpath> |
1099 |
|
|
1100 |
<formatter type="plain" /> |
|
1101 |
|
|
1102 |
<batchtest fork="yes" todir="${build.dir}"> |
|
1103 |
<fileset dir="${build.tests}"> |
|
1104 |
<include name="**/*.class" /> |
|
1105 |
<exclude name="**/MCTestCase.class" /> |
|
1106 |
<exclude name="**/ClientViewHelperTest.class" /> |
|
1107 |
<!-- these are not test cases --> |
|
1108 |
<exclude name="**/MockCNode.class" /> |
|
1109 |
<exclude name="**/D1NodeServiceTest.class" /> |
|
1110 |
</fileset> |
|
1111 |
</batchtest> |
|
1112 |
</junit> |
|
1098 |
</java> |
|
1113 | 1099 |
</target> |
1114 | 1100 |
|
1115 | 1101 |
<target name="runonetest" depends="testprep" |
... | ... | |
1140 | 1126 |
</batchtest> |
1141 | 1127 |
</junit> |
1142 | 1128 |
</target> |
1129 |
|
|
1130 |
<target name="run" depends="testprep" |
|
1131 |
description="Uses the ant junit task to run a single JUnit test, defined by the ${testtorun} property"> |
|
1143 | 1132 |
|
1133 |
<echo>testtorun: ${testtorun}</echo> |
|
1134 |
|
|
1135 |
<!-- use the ant "junit" task to run JUnit tests. --> |
|
1136 |
<junit printsummary="yes" haltonfailure="no" fork="yes" |
|
1137 |
haltonerror="no" showoutput="yes"> |
|
1138 |
<jvmarg value="-Dfile.encoding=UTF-8"/> |
|
1139 |
<classpath> |
|
1140 |
<path refid="test.classpath" /> |
|
1141 |
<fileset dir="${build.dir}"> |
|
1142 |
<include name="${name}.jar" /> |
|
1143 |
<include name="${name}-client.jar" /> |
|
1144 |
<include name="harvester.jar" /> |
|
1145 |
<include name="${name}-junittests.jar" /> |
|
1146 |
</fileset> |
|
1147 |
</classpath> |
|
1148 |
|
|
1149 |
<formatter type="plain" /> |
|
1150 |
|
|
1151 |
<batchtest fork="yes" todir="${build.dir}"> |
|
1152 |
<fileset dir="${build.tests}"> |
|
1153 |
<include name="**/${testtorun}.class" /> |
|
1154 |
</fileset> |
|
1155 |
</batchtest> |
|
1156 |
</junit> |
|
1157 |
</target> |
|
1158 |
|
|
1144 | 1159 |
<target name="testharvester" depends="testprep" |
1145 | 1160 |
description="Uses the ant junit task to test only the Harvester code"> |
1146 | 1161 |
<junit printsummary="yes" haltonfailure="off" fork="yes" |
Also available in: Unified diff
upgrade to hazelcast 1.9.4.6 so that threadpools are released when not needed (http://code.google.com/p/hazelcast/issues/detail?id=765).
include ant target to run a specific main class (mostly for debugging)