.withType(Type.PASSIVE) .withStorage(Storage.builder().withStorageLevel(StorageLevel.MEMORY).build()) .withStateMachine(() -> new EchoJournalStateMachine(lastUpdate)).build();
.build(); mPrimarySelector.init(mServer);
.withMajorCompactionInterval(Duration.ofMinutes(15)) .build()) .build();
/** * Builds the server. * <p> * If no {@link Transport} was configured for the server, the builder will attempt to create a * {@code NettyTransport} instance. If {@code io.atomix.catalyst.transport.netty.NettyTransport} is not available * on the classpath, a {@link ConfigurationException} will be thrown. * <p> * Once the server is built, it is not yet connected to the cluster. To connect the server to the cluster, * call the asynchronous {@link #bootstrap()} or {@link #join(Address...)} method. * * @return The built server. * @throws ConfigurationException if the server is misconfigured */ @Override public ResourceServer build() { // Construct the underlying CopycatServer. The server should have been configured with a CombinedTransport // that facilitates the local client connecting directly to the server. CopycatServer server = builder.withStateMachine(ResourceManagerState::new).build(); server.serializer().resolve(new ResourceManagerTypeResolver()); for (ResourceType type : registry.types()) { try { type.factory().newInstance().createSerializableTypeResolver().resolve(server.serializer().registry()); } catch (InstantiationException | IllegalAccessException e) { throw new ResourceManagerException(e); } } return new ResourceServer(server); } }
/** * Builds the server. * <p> * If no {@link Transport} was configured for the server, the builder will attempt to create a * {@code NettyTransport} instance. If {@code io.atomix.catalyst.transport.NettyTransport} is not available * on the classpath, a {@link ConfigurationException} will be thrown. * <p> * Once the server is built, it is not yet connected to the cluster. To connect the server to the cluster, * call the asynchronous {@link #open()} method. * * @return The built server. * @throws ConfigurationException if the server is misconfigured */ @Override public ResourceServer build() { // Create a resource registry and resolve resources with the configured resolver. ResourceRegistry registry = new ResourceRegistry(); resourceResolver.resolve(registry); // Construct the underlying CopycatServer. The server should have been configured with a CombinedTransport // that facilitates the local client connecting directly to the server. CopycatServer server = builder.withStateMachine(() -> new ResourceManagerState(registry)).build(); server.serializer().resolve(new ResourceManagerTypeResolver(registry)); return new ResourceServer(server); } }
/** * Creates a Raft server. */ @SuppressWarnings("unchecked") protected CopycatServer createServer(Address address, Resource.Config config) throws Throwable { ResourceType type = new ResourceType((Class<? extends Resource>) type()); Supplier<StateMachine> stateMachine = () -> { try { return type.factory().newInstance().createStateMachine(config); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } }; CopycatServer server = CopycatServer.builder(address) .withTransport(new LocalTransport(registry)) .withStorage(new Storage(StorageLevel.MEMORY)) .withStateMachine(stateMachine) .build(); type.factory().newInstance().createSerializableTypeResolver().resolve(server.serializer().registry()); servers.add(server); return server; }
/** * Creates a Copycat server. */ private CopycatServer createServer(Member member) { CopycatServer.Builder builder = CopycatServer.builder(member.clientAddress(), member.serverAddress()) .withType(member.type()) .withTransport(new NettyTransport()) .withStorage(Storage.builder() .withStorageLevel(StorageLevel.DISK) .withDirectory(new File(String.format("target/fuzz-logs/%d", member.address().hashCode()))) .withMaxSegmentSize(randomNumber(1024 * 1024 * 7) + (1024 * 1024)) .withMaxEntriesPerSegment(randomNumber(10000) + 1000) .withCompactionThreads(randomNumber(4) + 1) .withCompactionThreshold(Math.random() / (double) 2) .withEntryBufferSize(randomNumber(10000) + 1) .withFlushOnCommit(randomBoolean()) .withMinorCompactionInterval(Duration.ofSeconds(randomNumber(30) + 15)) .withMajorCompactionInterval(Duration.ofSeconds(randomNumber(60) + 60)) .build()) .withStateMachine(FuzzStateMachine::new); CopycatServer server = builder.build(); server.serializer().disableWhitelist(); servers.add(server); return server; }
/** * Builds a server for the replica. */ private ResourceServer buildServer() { // Construct the underlying CopycatServer. The server should have been configured with a CombinedTransport // that facilitates the local client connecting directly to the server. if (clientTransport != null) { serverBuilder.withClientTransport(new CombinedServerTransport(new LocalTransport(localRegistry), clientTransport)) .withServerTransport(serverTransport); } else { serverBuilder.withTransport(new CombinedServerTransport(new LocalTransport(localRegistry), serverTransport)); } // Set the server resource state machine. serverBuilder.withStateMachine(() -> new ResourceManagerState(registry)); // If the quorum hint is ALL then set the local member to ACTIVE. if (quorumHint == Quorum.ALL.size()) { serverBuilder.withType(Member.Type.ACTIVE); } CopycatServer server = serverBuilder.build(); server.serializer().resolve(new ResourceManagerTypeResolver(registry)); return new ResourceServer(server); }
/** * Creates a Copycat server. */ private CopycatServer createServer(Member member) { CopycatServer.Builder builder = CopycatServer.builder(member.clientAddress(), member.serverAddress()) .withType(member.type()) .withTransport(new NettyTransport()) .withStorage(Storage.builder() .withStorageLevel(StorageLevel.DISK) .withDirectory(new File(String.format("target/performance-logs/%d", member.address().hashCode()))) .withCompactionThreads(1) .build()) .withStateMachine(PerformanceStateMachine::new); CopycatServer server = builder.build(); server.serializer().disableWhitelist(); servers.add(server); return server; }
/** * Creates a Copycat server. */ private CopycatServer createServer(Member member) { CopycatServer.Builder builder = CopycatServer.builder(member.clientAddress(), member.serverAddress()) .withType(member.type()) .withTransport(new LocalTransport(registry)) .withStorage(Storage.builder() .withStorageLevel(StorageLevel.MEMORY) .withMaxSegmentSize(1024 * 1024) .withCompactionThreads(1) .build()) .withStateMachine(TestStateMachine::new); CopycatServer server = builder.build(); server.serializer().disableWhitelist(); servers.add(server); return server; }
private CopycatServer createCopyCatServer() { return CopycatServer.builder(new Address(bindHost, bindPort)) .withStorage(new Storage(StorageLevel.MEMORY)) .withStateMachine(() -> stateMachine) .build(); }