Search in sources :

Example 11 with ObjectStreamFactory

use of org.neo4j.cluster.protocol.atomicbroadcast.ObjectStreamFactory in project neo4j by neo4j.

the class MemberIsUnavailableTest method serialize.

private static byte[] serialize(MemberIsUnavailable message) throws IOException {
    ObjectOutputStream outputStream = null;
    try {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        outputStream = new ObjectStreamFactory().create(byteArrayOutputStream);
        outputStream.writeObject(message);
        return byteArrayOutputStream.toByteArray();
    } finally {
        if (outputStream != null) {
            outputStream.close();
        }
    }
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ObjectStreamFactory(org.neo4j.cluster.protocol.atomicbroadcast.ObjectStreamFactory)

Example 12 with ObjectStreamFactory

use of org.neo4j.cluster.protocol.atomicbroadcast.ObjectStreamFactory in project neo4j by neo4j.

the class ClusterInstance method newClusterInstance.

public static ClusterInstance newClusterInstance(InstanceId id, URI uri, Monitors monitors, ClusterConfiguration configuration, int maxSurvivableFailedMembers, LogProvider logging) {
    MultiPaxosServerFactory factory = new MultiPaxosServerFactory(configuration, logging, monitors.newMonitor(StateMachines.Monitor.class));
    ClusterInstanceInput input = new ClusterInstanceInput();
    ClusterInstanceOutput output = new ClusterInstanceOutput(uri);
    ObjectStreamFactory objStreamFactory = new ObjectStreamFactory();
    ProverTimeouts timeouts = new ProverTimeouts(uri);
    InMemoryAcceptorInstanceStore acceptorInstances = new InMemoryAcceptorInstanceStore();
    Config config = mock(Config.class);
    when(config.get(ClusterSettings.max_acceptors)).thenReturn(maxSurvivableFailedMembers);
    DelayedDirectExecutor executor = new DelayedDirectExecutor(logging);
    final MultiPaxosContext context = new MultiPaxosContext(id, Iterables.<ElectionRole, ElectionRole>iterable(new ElectionRole(ClusterConfiguration.COORDINATOR)), new ClusterConfiguration(configuration.getName(), logging, configuration.getMemberURIs()), executor, logging, objStreamFactory, objStreamFactory, acceptorInstances, timeouts, new DefaultElectionCredentialsProvider(id, new StateVerifierLastTxIdGetter(), new MemberInfoProvider()), config);
    context.getClusterContext().setBoundAt(uri);
    SnapshotContext snapshotContext = new SnapshotContext(context.getClusterContext(), context.getLearnerContext());
    DelayedDirectExecutor taskExecutor = new DelayedDirectExecutor(logging);
    ProtocolServer ps = factory.newProtocolServer(id, input, output, DIRECT_EXECUTOR, taskExecutor, timeouts, context, snapshotContext);
    return new ClusterInstance(DIRECT_EXECUTOR, logging, factory, ps, context, acceptorInstances, timeouts, input, output, uri);
}
Also used : Config(org.neo4j.kernel.configuration.Config) HighAvailabilityMemberInfoProvider(org.neo4j.kernel.ha.HighAvailabilityMemberInfoProvider) DelayedDirectExecutor(org.neo4j.cluster.DelayedDirectExecutor) ClusterConfiguration(org.neo4j.cluster.protocol.cluster.ClusterConfiguration) DefaultElectionCredentialsProvider(org.neo4j.kernel.ha.cluster.DefaultElectionCredentialsProvider) ElectionRole(org.neo4j.cluster.protocol.election.ElectionRole) ObjectStreamFactory(org.neo4j.cluster.protocol.atomicbroadcast.ObjectStreamFactory) SnapshotContext(org.neo4j.cluster.protocol.snapshot.SnapshotContext) ProtocolServer(org.neo4j.cluster.ProtocolServer) MultiPaxosContext(org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.context.MultiPaxosContext) MultiPaxosServerFactory(org.neo4j.cluster.MultiPaxosServerFactory) InMemoryAcceptorInstanceStore(org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InMemoryAcceptorInstanceStore)

Aggregations

ObjectStreamFactory (org.neo4j.cluster.protocol.atomicbroadcast.ObjectStreamFactory)12 AtomicBroadcastSerializer (org.neo4j.cluster.protocol.atomicbroadcast.AtomicBroadcastSerializer)6 Test (org.junit.Test)5 ClusterConfiguration (org.neo4j.cluster.protocol.cluster.ClusterConfiguration)5 URI (java.net.URI)4 InstanceId (org.neo4j.cluster.InstanceId)4 MultiPaxosContext (org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.context.MultiPaxosContext)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 AtomicBroadcast (org.neo4j.cluster.protocol.atomicbroadcast.AtomicBroadcast)3 AtomicBroadcastListener (org.neo4j.cluster.protocol.atomicbroadcast.AtomicBroadcastListener)3 Payload (org.neo4j.cluster.protocol.atomicbroadcast.Payload)3 InMemoryAcceptorInstanceStore (org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InMemoryAcceptorInstanceStore)3 Config (org.neo4j.kernel.configuration.Config)3 Executor (java.util.concurrent.Executor)2 DelayedDirectExecutor (org.neo4j.cluster.DelayedDirectExecutor)2 MultiPaxosServerFactory (org.neo4j.cluster.MultiPaxosServerFactory)2 ProtocolServer (org.neo4j.cluster.ProtocolServer)2 TestProtocolServer (org.neo4j.cluster.TestProtocolServer)2 Cluster (org.neo4j.cluster.protocol.cluster.Cluster)2