public static <T> IPromise<IPromise<T>[]> all(int count, Function<Integer,IPromise<T>> loop) { IPromise<T> promis[] = new IPromise[count]; for ( int i = 0; i < count; i++ ) { promis[i] = loop.apply(i); } return all(promis); }
public static <T> IPromise<IPromise<T>[]> all(int count, Function<Integer,IPromise<T>> loop) { IPromise<T> promis[] = new IPromise[count]; for ( int i = 0; i < count; i++ ) { promis[i] = loop.apply(i); } return all(promis); }
@Override public IPromise dropTable(String name) { ArrayList<IPromise<Object>> results = new ArrayList(); for (int i = 0; i < shards.size(); i++) { TableSpaceActor shard = shards.get(i); results.add(shard.dropTable(name)); } return Actors.all(results); }
@Override public IPromise ping() { List<IPromise<Object>> futs = new ArrayList(); return Actors.all( shards.stream().map( shard -> shard.ping() ).collect(Collectors.toList())); }
public IPromise resizeIfLoadFactorLarger(double loadFactor, long maxGrowBytes) { List<IPromise<Object>> futs = new ArrayList(); shards.forEach( shard -> futs.add(shard.resizeIfLoadFactorLarger(loadFactor,maxGrowBytes)) ); return Actors.all(futs); }
@Override public IPromise<Long> size() { Promise result = new Promise(); Actors.all(shards.stream().map( shard -> shard.size() ).collect(Collectors.toList())) .then( longPromisList -> { long sum = longPromisList.stream().mapToLong(prom -> prom.get()).sum(); result.resolve(sum); }); return result; }
/** * await until all futures are settled and stream their results */ public static <T> Stream<T> awaitAll(long timeoutMS, IPromise<T>... futures) { return streamHelper(all(futures).await(timeoutMS)); }
/** * await until all futures are settled and stream their results. Uses Actors.DEFAULT_TIMEOUT */ public static <T> Stream<T> awaitAll(IPromise<T>... futures) { return streamHelper(all(futures).await()); }
/** * await until all futures are settled and stream their results. Uses Actors.DEFAULT_TIMEOUT */ public static <T> Stream<T> awaitAll(IPromise<T>... futures) { return streamHelper(all(futures).await()); }
/** * await until all futures are settled and stream their results */ public static <T> Stream<T> awaitAll(long timeoutMS, IPromise<T>... futures) { return streamHelper(all(futures).await(timeoutMS)); }
public static <T> Stream<T> awaitAll(long timeoutMS, List<IPromise<T>> futures) { return streamHelper(all(futures).await(timeoutMS)); }
public static <T> Stream<T> awaitAll(long timeoutMS, List<IPromise<T>> futures) { return streamHelper(all(futures).await(timeoutMS)); }
public static <T> Stream<T> awaitAll(List<IPromise<T>> futures) { return streamHelper(all(futures).await()); }
public static <T> Stream<T> awaitAll(List<IPromise<T>> futures) { return streamHelper(all(futures).await()); }
@Override public IPromise<StorageStats> getStats() { Promise res = new Promise(); try { Actors.all(shards.stream().map( shard -> shard.getStats() ).collect(Collectors.toList())) .then( (shardStats,err) -> { if (shardStats!=null) { StorageStats stats = new StorageStats(); shardStats.stream().map( fut -> fut.get() ).forEach( nodeStats -> nodeStats.addTo(stats)); res.resolve(stats); } else { res.reject(err); } }); } catch (Exception e) { Log.Warn(this,e); res.reject(e); } return res; }
reply.run(); } else { Actors.all((List) futures).timeoutIn(REQUEST_RESULTING_FUTURE_TIMEOUT).then( () -> { reply.run(); }).onTimeout( () -> reply.run() );
reply.run(); } else { Actors.all((List) futures).timeoutIn(REQUEST_RESULTING_FUTURE_TIMEOUT).then( () -> { reply.run(); }).onTimeout( () -> reply.run() );
}); List<IPromise<RealLiveTable>> tables = Actors.all(results).await();