Search in sources :

Example 1 with ClientImpl

use of com.linkedin.parseq.example.composite.classifier.client.impl.ClientImpl in project parseq by linkedin.

the class ClassifierDriver method main.

public static void main(String[] args) throws InterruptedException {
    final long viewerId = 0;
    final Set<Long> unclassified = new HashSet<Long>();
    for (long i = 0; i < 20; i++) {
        unclassified.add(i);
    }
    final ScheduledExecutorService serviceScheduler = Executors.newSingleThreadScheduledExecutor();
    final Client restLiClient = new ClientImpl(serviceScheduler);
    final int numCores = Runtime.getRuntime().availableProcessors();
    final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(numCores + 1);
    final Engine engine = new EngineBuilder().setTaskExecutor(scheduler).setTimerScheduler(scheduler).build();
    final ClassifierPlanFactory classifier = new ClassifierPlanFactory(restLiClient);
    try {
        final Task<Map<Long, Classification>> classifications = classifier.classify(viewerId, unclassified);
        engine.run(classifications);
        classifications.await();
        System.out.println(classifications.get());
        ExampleUtil.printTracingResults(classifications);
    } finally {
        serviceScheduler.shutdownNow();
        engine.shutdown();
        scheduler.shutdownNow();
    }
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ClientImpl(com.linkedin.parseq.example.composite.classifier.client.impl.ClientImpl) Client(com.linkedin.parseq.example.composite.classifier.client.Client) EngineBuilder(com.linkedin.parseq.EngineBuilder) Map(java.util.Map) Engine(com.linkedin.parseq.Engine) HashSet(java.util.HashSet)

Aggregations

Engine (com.linkedin.parseq.Engine)1 EngineBuilder (com.linkedin.parseq.EngineBuilder)1 Client (com.linkedin.parseq.example.composite.classifier.client.Client)1 ClientImpl (com.linkedin.parseq.example.composite.classifier.client.impl.ClientImpl)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1