use of java.util.concurrent.ConcurrentHashMap in project DataX by alibaba.
the class ProcessInnerReporterTest method testReportTGCommunication.
@Test
public void testReportTGCommunication() throws NoSuchFieldException, IllegalAccessException {
Integer taskGroupId = 1;
Communication communication = new Communication();
communication.setState(State.SUBMITTING);
ConcurrentHashMap<Integer, Communication> map = new ConcurrentHashMap<Integer, Communication>();
map.put(taskGroupId, communication);
ReflectUtil.setField(new LocalTGCommunicationManager(), "taskGroupCommunicationMap", map);
ProcessInnerReporter processInnerReporter = new ProcessInnerReporter();
Communication updateCommunication = new Communication();
updateCommunication.setState(State.WAITING);
processInnerReporter.reportTGCommunication(taskGroupId, updateCommunication);
Assert.assertEquals(map.get(taskGroupId).getState(), State.WAITING);
}
use of java.util.concurrent.ConcurrentHashMap in project eureka by Netflix.
the class DiscoveryClient method filterAndShuffle.
/**
* Gets the <em>applications</em> after filtering the applications for
* instances with only UP states and shuffling them.
*
* <p>
* The filtering depends on the option specified by the configuration
* {@link EurekaClientConfig#shouldFilterOnlyUpInstances()}. Shuffling helps
* in randomizing the applications list there by avoiding the same instances
* receiving traffic during start ups.
* </p>
*
* @param apps
* The applications that needs to be filtered and shuffled.
* @return The applications after the filter and the shuffle.
*/
private Applications filterAndShuffle(Applications apps) {
if (apps != null) {
if (isFetchingRemoteRegionRegistries()) {
Map<String, Applications> remoteRegionVsApps = new ConcurrentHashMap<String, Applications>();
apps.shuffleAndIndexInstances(remoteRegionVsApps, clientConfig, instanceRegionChecker);
for (Applications applications : remoteRegionVsApps.values()) {
applications.shuffleInstances(clientConfig.shouldFilterOnlyUpInstances());
}
this.remoteRegionVsApps = remoteRegionVsApps;
} else {
apps.shuffleInstances(clientConfig.shouldFilterOnlyUpInstances());
}
}
return apps;
}
use of java.util.concurrent.ConcurrentHashMap in project atlas by alibaba.
the class TPatchTool method main.
// public static void main(String[] args) throws Exception {
// File newApk = new File("/Users/shenghua/Downloads/tpatch/new.apk");
// File baseApk = new File("/Users/shenghua/Downloads/tpatch/base.apk");
// File atalsPatchFoder = new File("/Users/shenghua/Downloads/tpatch/tpatch");
// atalsPatchFoder.mkdirs();
// TPatchTool tPatchTool = new TPatchTool(baseApk, newApk, "5.5.3.39", "5.5.3.40", true);
// tPatchTool.setMainBundleName("libcom_taobao_maindex");
// tPatchTool.setNotIncludeFiles(new String[] { "lib/x86/**" });
// tPatchTool.setRetainMainBundleRes(false);
// List<ArtifactBundleInfo> bundleInfoList = new ArrayList<ArtifactBundleInfo>();
// Set<ArtifactBundleInfo> artifactBundleInfos = Sets.newHashSet();
// bundleInfoList = JSON.parseArray(FileUtils.readFileToString(new File("/Users/shenghua/Downloads/tpatch/tpatch-bundles.json")),
// ArtifactBundleInfo.class);
// artifactBundleInfos.addAll(bundleInfoList);
// tPatchTool.setArtifactBundleInfos(artifactBundleInfos);
// tPatchTool.setOnlyIncludeModifyBundle(true);
// tPatchTool.doPatch(atalsPatchFoder, true, new File(atalsPatchFoder, "patchs.json"), false, null, "");
// }
public static void main(String[] args) throws Exception {
// String response = HttpClientUtils.getUrl(url);
// if (response.equals("\"\"")){
// System.out.println("xxx");
// }
// String aaa = StringEscapeUtils.unescapeJava(response);
// URL url1 = new URL(aaa.substring(1,aaa.length()-1));
//// downloadTPath(aaa.substring(1,aaa.length()-1), new File("/Users/lilong/Downloads/1111.patch"));
//// PatchUtils.getTpatchClassDef(lastPatchFile, bundleClassMap)
Map<String, Map<String, ClassDef>> bundleClassMap = new ConcurrentHashMap<String, Map<String, ClassDef>>();
PatchUtils.getTpatchClassDef(new File("/Users/lilong/Downloads/temp/patch-6.1.1@6.1.0.zip"), bundleClassMap);
System.out.println(bundleClassMap.size());
TPatchTool tPatchTool = new TPatchTool(new File("/Users/lilong/Downloads/taobao-android.apk"), new File("/Users/lilong/Downloads/tpatch-diff.apk"), "1.0.0", "2.0.0", true);
tPatchTool.bundleClassMap = bundleClassMap;
tPatchTool.doPatch(new File("/Users/lilong/Downloads/aaa"), false, null, true, null, "taobao4android");
//
// TPatchDexTool dexTool = new TPatchDexTool(new File("/Users/lilong/Downloads/10006492@taobao_android_5.7.2/classes.dex"), new File("/Users/lilong/Downloads/taobao-android/classes.dex"), DEFAULT_API_LEVEL);
// File dexDiffFile = new File(new File("/Users/lilong/Downloads/10006492@taobao_android_5.7.2"), "diff.dex");
// DexDiffInfo dexDiffInfo = dexTool.createTPatchDex(dexDiffFile);
// TPatchTool.debug = true;
// TPatchTool.isTpatch = true;
//
// TPatchTool tPatchTool = new TPatchTool(new File("/Users/lilong/Downloads/taobao-android3.apk"), new File("/Users/lilong/Downloads/tpatch-diff.apk"),"5.8.0","5.8.4", true);
//
// File dexDiffFile = new File("/Users/lilong/Downloads/taobao-android");
// tPatchTool.doPatch(dexDiffFile,false,null,false,null,null);
}
use of java.util.concurrent.ConcurrentHashMap in project buck by facebook.
the class WorkerShellStepTest method createExecutionContextWith.
private ExecutionContext createExecutionContextWith(final ImmutableMap<String, WorkerJobResult> jobArgs, final int poolCapacity) {
WorkerProcessPool workerProcessPool = new WorkerProcessPool(poolCapacity, Hashing.sha1().hashString(fakeWorkerStartupCommand, Charsets.UTF_8)) {
@Override
protected WorkerProcess startWorkerProcess() throws IOException {
return new FakeWorkerProcess(jobArgs);
}
};
ConcurrentHashMap<String, WorkerProcessPool> workerProcessMap = new ConcurrentHashMap<>();
workerProcessMap.put(fakeWorkerStartupCommand, workerProcessPool);
WorkerProcessPool persistentWorkerProcessPool = new WorkerProcessPool(poolCapacity, Hashing.sha1().hashString(fakePersistentWorkerStartupCommand, Charsets.UTF_8)) {
@Override
protected WorkerProcess startWorkerProcess() throws IOException {
return new FakeWorkerProcess(jobArgs);
}
};
ConcurrentHashMap<String, WorkerProcessPool> persistentWorkerProcessMap = new ConcurrentHashMap<>();
persistentWorkerProcessMap.put(persistentWorkerKey, persistentWorkerProcessPool);
ExecutionContext context = TestExecutionContext.newBuilder().setPlatform(Platform.LINUX).setWorkerProcessPools(workerProcessMap).setPersistentWorkerPools(persistentWorkerProcessMap).setConsole(new TestConsole(Verbosity.ALL)).setBuckEventBus(BuckEventBusFactory.newInstance()).build();
return context;
}
use of java.util.concurrent.ConcurrentHashMap in project neo4j by neo4j.
the class InMemoryCountsStoreCountsSnapshotSerializerTest method setup.
@Before
public void setup() throws IOException {
logChannel = new InMemoryClosableChannel();
countsSnapshot = new CountsSnapshot(1, new ConcurrentHashMap<>());
}
Aggregations