Search in sources :

Example 66 with ConcurrentHashMap

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);
}
Also used : ProcessInnerReporter(com.alibaba.datax.core.statistics.container.report.ProcessInnerReporter) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LocalTGCommunicationManager(com.alibaba.datax.core.statistics.communication.LocalTGCommunicationManager) Communication(com.alibaba.datax.core.statistics.communication.Communication) Test(org.junit.Test)

Example 67 with ConcurrentHashMap

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;
}
Also used : Applications(com.netflix.discovery.shared.Applications) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 68 with ConcurrentHashMap

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);
}
Also used : ClassDef(org.jf.dexlib2.iface.ClassDef) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) File(java.io.File)

Example 69 with ConcurrentHashMap

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;
}
Also used : ExecutionContext(com.facebook.buck.step.ExecutionContext) TestExecutionContext(com.facebook.buck.step.TestExecutionContext) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TestConsole(com.facebook.buck.testutil.TestConsole)

Example 70 with ConcurrentHashMap

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<>());
}
Also used : InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Before(org.junit.Before)

Aggregations

ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)420 Map (java.util.Map)106 Test (org.junit.Test)102 HashMap (java.util.HashMap)75 ArrayList (java.util.ArrayList)73 CountDownLatch (java.util.concurrent.CountDownLatch)53 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)49 IOException (java.io.IOException)47 List (java.util.List)38 Set (java.util.Set)36 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)33 HashSet (java.util.HashSet)31 AtomicLong (java.util.concurrent.atomic.AtomicLong)29 ConcurrentMap (java.util.concurrent.ConcurrentMap)28 Random (java.util.Random)25 ExecutorService (java.util.concurrent.ExecutorService)23 Collection (java.util.Collection)20 UUID (java.util.UUID)20 Iterator (java.util.Iterator)19 Configuration (org.apache.hadoop.conf.Configuration)17