@Override public ActorFuture<S> install() { final ActorFuture<S> installFuture = super.install(); installFutures.put(serviceName, (ActorFuture) installFuture); return (ActorFuture) installFuture; } }
@Override public ActorFuture<S> install() { final ActorFuture<S> installFuture = super.install(); installFutures.put(serviceName, (ActorFuture) installFuture); return (ActorFuture) installFuture; } }
public CompositeServiceBuilder( ServiceName<Void> name, ServiceContainer container, ServiceName<?>... additionalDependencies) { this.compositeServiceName = name; this.container = (ServiceContainerImpl) container; final ServiceBuilder<Void> installServiceBuilder = container.createService(compositeServiceName, new CompositeService()); for (ServiceName<?> serviceName : additionalDependencies) { installServiceBuilder.dependency(serviceName); } installFutures.put(compositeServiceName, (ActorFuture) installServiceBuilder.install()); }
public CompositeServiceBuilder( ServiceName<Void> name, ServiceContainer container, ServiceName<?>... additionalDependencies) { this.compositeServiceName = name; this.container = (ServiceContainerImpl) container; final ServiceBuilder<Void> installServiceBuilder = container.createService(compositeServiceName, new CompositeService()); for (ServiceName<?> serviceName : additionalDependencies) { installServiceBuilder.dependency(serviceName); } installFutures.put(compositeServiceName, (ActorFuture) installServiceBuilder.install()); }
protected ActorFuture<ClientTransport> createClientTransport( final ServiceContainer serviceContainer, final String name, final ByteValue sendBufferSize, final Collection<IntTuple<SocketAddress>> defaultEndpoints) { final ClientTransportService service = new ClientTransportService(name, defaultEndpoints, sendBufferSize); return serviceContainer .createService(TransportServiceNames.clientTransport(name), service) .install(); } }
protected ActorFuture<ClientTransport> createClientTransport( final ServiceContainer serviceContainer, final String name, final ByteValue sendBufferSize, final Collection<IntTuple<SocketAddress>> defaultEndpoints) { final ClientTransportService service = new ClientTransportService(name, defaultEndpoints, sendBufferSize); return serviceContainer .createService(TransportServiceNames.clientTransport(name), service) .install(); } }
protected void createDispatcher( final ServiceContainer serviceContainer, final ServiceName<Dispatcher> name, final ByteValue sendBufferSize) { final DispatcherBuilder dispatcherBuilder = Dispatchers.create(null).bufferSize(sendBufferSize); final DispatcherService receiveBufferService = new DispatcherService(dispatcherBuilder); serviceContainer.createService(name, receiveBufferService).install(); }
protected void createDispatcher( final ServiceContainer serviceContainer, final ServiceName<Dispatcher> name, final ByteValue sendBufferSize) { final DispatcherBuilder dispatcherBuilder = Dispatchers.create(null).bufferSize(sendBufferSize); final DispatcherService receiveBufferService = new DispatcherService(dispatcherBuilder); serviceContainer.createService(name, receiveBufferService).install(); }
public <T> void installService( Function<ServiceContainer, ServiceBuilder<T>> serviceBuilderFactory) { final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer(); final ServiceBuilder<T> serviceBuilder = serviceBuilderFactory.apply(serviceContainer); try { serviceBuilder.install().get(10, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException("Could not install service: " + serviceBuilder.getName(), e); } }
@Override public void onRecovered(TypedStreamProcessor streamProcessor) { final WorkflowRepositoryService workflowRepositoryService = new WorkflowRepositoryService(streamProcessor.getActor(), workflowState); startContext .createService(WORKFLOW_REPOSITORY_SERVICE, workflowRepositoryService) .dependency(partitionServiceName) .install(); getWorkflowMessageHandler.setWorkflowRepositoryService(workflowRepositoryService); listWorkflowsControlMessageHandler.setWorkflowRepositoryService(workflowRepositoryService); }
@Override public void onRecovered(TypedStreamProcessor streamProcessor) { final WorkflowRepositoryService workflowRepositoryService = new WorkflowRepositoryService(streamProcessor.getActor(), workflowState); startContext .createService(WORKFLOW_REPOSITORY_SERVICE, workflowRepositoryService) .dependency(partitionServiceName) .install(); getWorkflowMessageHandler.setWorkflowRepositoryService(workflowRepositoryService); listWorkflowsControlMessageHandler.setWorkflowRepositoryService(workflowRepositoryService); }
public <T> void installService( Function<ServiceContainer, ServiceBuilder<T>> serviceBuilderFactory) { final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer(); final ServiceBuilder<T> serviceBuilder = serviceBuilderFactory.apply(serviceContainer); try { serviceBuilder.install().get(10, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException("Could not install service: " + serviceBuilder.getName(), e); } }
private void installFollowerPartition(final Raft raft) { final Partition partition = new Partition(partitionInfo, RaftState.FOLLOWER); final ServiceName<Partition> partitionServiceName = followerPartitionServiceName(raft.getName()); if (!startContext.hasService(partitionServiceName)) { LOG.debug("Installing follower partition service for {}", partitionInfo); startContext .createService(partitionServiceName, partition) .dependency(logStreamServiceName, partition.getLogStreamInjector()) .dependency(stateStorageFactoryServiceName, partition.getStateStorageFactoryInjector()) .group(FOLLOWER_PARTITION_GROUP_NAME) .install(); } }
private void installFollowerPartition(final Raft raft) { final Partition partition = new Partition(partitionInfo, RaftState.FOLLOWER); final ServiceName<Partition> partitionServiceName = followerPartitionServiceName(raft.getName()); if (!startContext.hasService(partitionServiceName)) { LOG.debug("Installing follower partition service for {}", partitionInfo); startContext .createService(partitionServiceName, partition) .dependency(logStreamServiceName, partition.getLogStreamInjector()) .dependency(stateStorageFactoryServiceName, partition.getStateStorageFactoryInjector()) .group(FOLLOWER_PARTITION_GROUP_NAME) .install(); } }
private void installPartition( final ServiceStartContext startContext, final RaftPersistentConfiguration configuration) { final String partitionName = Partition.getPartitionName(configuration.getPartitionId()); final ServiceName<Void> partitionInstallServiceName = partitionInstallServiceName(partitionName); final PartitionInstallService partitionInstallService = new PartitionInstallService(brokerCfg, configuration); startContext .createService(partitionInstallServiceName, partitionInstallService) .dependency( clientTransport(REPLICATION_API_CLIENT_NAME), partitionInstallService.getClientTransportInjector()) .install(); }
private void installPartition( final ServiceStartContext startContext, final RaftPersistentConfiguration configuration) { final String partitionName = Partition.getPartitionName(configuration.getPartitionId()); final ServiceName<Void> partitionInstallServiceName = partitionInstallServiceName(partitionName); final PartitionInstallService partitionInstallService = new PartitionInstallService(brokerCfg, configuration); startContext .createService(partitionInstallServiceName, partitionInstallService) .dependency( clientTransport(REPLICATION_API_CLIENT_NAME), partitionInstallService.getClientTransportInjector()) .install(); }
@Override public void start(final ServiceStartContext startContext) { this.logStream = logStreamInjector.getValue(); this.logStream.setTerm(getTerm()); this.serviceContext = startContext; raftJoinedService = new RaftJoinService(this, actor); serviceContext.createService(joinServiceName(raftName), raftJoinedService).install(); startContext.async(startContext.getScheduler().submitActor(this, true)); }
@Override public void init(final SystemContext context) { final ServiceContainer serviceContainer = context.getServiceContainer(); final SubscriptionApiCommandMessageHandlerService messageHandlerService = new SubscriptionApiCommandMessageHandlerService(); serviceContainer .createService(SUBSCRIPTION_API_MESSAGE_HANDLER_SERVICE_NAME, messageHandlerService) .dependency( bufferingServerTransport(SUBSCRIPTION_API_SERVER_NAME), messageHandlerService.getServerTransportInjector()) .groupReference( LEADER_PARTITION_GROUP_NAME, messageHandlerService.getLeaderParitionsGroupReference()) .install(); } }
@Override public void start(final ServiceStartContext startContext) { this.logStream = logStreamInjector.getValue(); this.logStream.setTerm(getTerm()); this.serviceContext = startContext; raftJoinedService = new RaftJoinService(this, actor); serviceContext.createService(joinServiceName(raftName), raftJoinedService).install(); startContext.async(startContext.getScheduler().submitActor(this, true)); }
public <S> S getService(final ServiceName<S> serviceName) { final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer(); final Injector<S> injector = new Injector<>(); final ServiceName<TestService> accessorServiceName = ServiceName.newServiceName("serviceAccess" + serviceName.getName(), TestService.class); try { serviceContainer .createService(accessorServiceName, new TestService()) .dependency(serviceName, injector) .install() .get(); } catch (final InterruptedException | ExecutionException e) { throw new RuntimeException(e); } serviceContainer.removeService(accessorServiceName); return injector.getValue(); }