/** * Builds a new instance of the primitive. * <p> * The returned instance will be distinct from all other instances of the same primitive on this node, with a * distinct session, ordering guarantees, memory, etc. * * @return a new instance of the primitive */ @Override public P build() { try { return buildAsync().join(); } catch (Exception e) { if (e instanceof CompletionException && e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } else { throw e; } } }
/** * Gets or builds a singleton instance of the primitive. * <p> * The returned primitive will be shared by all {@code get()} calls for the named primitive. If no instance has yet * been constructed, the instance will be built from this builder's configuration. * * @return a singleton instance of the primitive */ public P get() { try { return getAsync().join(); } catch (Exception e) { if (e instanceof CompletionException && e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } else { throw e; } } }
protected <S> CompletableFuture<ProxyClient<S>> newProxy(Class<S> serviceType, ServiceConfig config) { PrimitiveProtocol protocol = protocol(); if (protocol instanceof ProxyProtocol) { try { return CompletableFuture.completedFuture(((ProxyProtocol) protocol) .newProxy(name, type, serviceType, config, managementService.getPartitionService())); } catch (Exception e) { return Futures.exceptionalFuture(e); } } return Futures.exceptionalFuture(new UnsupportedOperationException()); }
DistributedPrimitive primitive = builder.build(); return completionFunction.apply((Transactional<?>) primitive);
DistributedPrimitive primitive = builder.build(); return completionFunction.apply((Transactional<?>) primitive);
@Override @SuppressWarnings("unchecked") public <C extends PrimitiveConfig<C>, P extends SyncPrimitive> CompletableFuture<P> getPrimitiveAsync( String name, PrimitiveType<?, C, P> primitiveType, C primitiveConfig) { return cache.getPrimitive(name, () -> { C config = primitiveConfig; if (config == null) { config = configService.getConfig(name, primitiveType); } return primitiveType.newBuilder(name, config, managementService).buildAsync(); }); }
@Override @SuppressWarnings("unchecked") public <C extends PrimitiveConfig<C>, P extends SyncPrimitive> CompletableFuture<P> getPrimitiveAsync( String name, PrimitiveType<?, C, P> primitiveType, C primitiveConfig) { return cache.getPrimitive(name, () -> { C config = primitiveConfig; if (config == null) { config = configService.getConfig(name, primitiveType); } return primitiveType.newBuilder(name, config, managementService).buildAsync(); }); }