Search in sources :

Example 1 with ServiceContainer

use of com.quorum.tessera.service.ServiceContainer in project tessera by ConsenSys.

the class ScheduledServiceFactory method build.

public void build() {
    IntervalPropertyHelper intervalPropertyHelper = new IntervalPropertyHelper(config.getP2PServerConfig().getProperties());
    LOGGER.info("Creating p2p client");
    P2pClient p2pClient = P2pClient.create();
    LOGGER.info("Created p2p client {}", p2pClient);
    if (enableSync) {
        ResendPartyStore resendPartyStore = ResendPartyStore.create();
        TransactionRequester transactionRequester = TransactionRequester.create();
        SyncPoller syncPoller = new SyncPoller(resendPartyStore, transactionRequester, p2pClient);
        ScheduledExecutorService scheduledExecutorService = java.util.concurrent.Executors.newSingleThreadScheduledExecutor();
        tesseraScheduledExecutors.add(new TesseraScheduledExecutor(scheduledExecutorService, syncPoller, intervalPropertyHelper.syncInterval(), 5000L));
    }
    LOGGER.info("Creating EnclaveKeySynchroniser");
    final EnclaveKeySynchroniser enclaveKeySynchroniser = ServiceLoader.load(EnclaveKeySynchroniser.class).stream().map(ServiceLoader.Provider::get).findFirst().get();
    LOGGER.info("Created EnclaveKeySynchroniser {}", enclaveKeySynchroniser);
    tesseraScheduledExecutors.add(new TesseraScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor(), () -> enclaveKeySynchroniser.syncKeys(), intervalPropertyHelper.enclaveKeySyncInterval(), 5000L));
    LOGGER.info("Creating PartyInfoBroadcaster");
    PartyInfoBroadcaster partyInfoPoller = new PartyInfoBroadcaster(p2pClient);
    LOGGER.info("Created PartyInfoBroadcaster {}", partyInfoPoller);
    tesseraScheduledExecutors.add(new TesseraScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor(), partyInfoPoller, intervalPropertyHelper.partyInfoInterval(), 5000L));
    tesseraScheduledExecutors.forEach(TesseraScheduledExecutor::start);
    LOGGER.info("Creating Enclave");
    Enclave enclave = Enclave.create();
    LOGGER.info("Created Enclave {}", enclave);
    serviceContainer = new ServiceContainer(enclave);
    LOGGER.info("Starting Enclave");
    serviceContainer.start();
    LOGGER.info("Started Enclave");
}
Also used : TransactionRequester(com.quorum.tessera.p2p.resend.TransactionRequester) TesseraScheduledExecutor(com.quorum.tessera.threading.TesseraScheduledExecutor) ResendPartyStore(com.quorum.tessera.p2p.resend.ResendPartyStore) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) IntervalPropertyHelper(com.quorum.tessera.config.util.IntervalPropertyHelper) SyncPoller(com.quorum.tessera.p2p.resend.SyncPoller) ServiceContainer(com.quorum.tessera.service.ServiceContainer) P2pClient(com.quorum.tessera.partyinfo.P2pClient) Enclave(com.quorum.tessera.enclave.Enclave) PartyInfoBroadcaster(com.quorum.tessera.p2p.partyinfo.PartyInfoBroadcaster) EnclaveKeySynchroniser(com.quorum.tessera.discovery.EnclaveKeySynchroniser)

Aggregations

IntervalPropertyHelper (com.quorum.tessera.config.util.IntervalPropertyHelper)1 EnclaveKeySynchroniser (com.quorum.tessera.discovery.EnclaveKeySynchroniser)1 Enclave (com.quorum.tessera.enclave.Enclave)1 PartyInfoBroadcaster (com.quorum.tessera.p2p.partyinfo.PartyInfoBroadcaster)1 ResendPartyStore (com.quorum.tessera.p2p.resend.ResendPartyStore)1 SyncPoller (com.quorum.tessera.p2p.resend.SyncPoller)1 TransactionRequester (com.quorum.tessera.p2p.resend.TransactionRequester)1 P2pClient (com.quorum.tessera.partyinfo.P2pClient)1 ServiceContainer (com.quorum.tessera.service.ServiceContainer)1 TesseraScheduledExecutor (com.quorum.tessera.threading.TesseraScheduledExecutor)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1