Search in sources :

Example 11 with RequestContext

use of org.neo4j.com.RequestContext in project neo4j by neo4j.

the class BackupProtocolTest method shouldHandleNoForensicsSpecifiedInFullBackupRequest.

@Test
public void shouldHandleNoForensicsSpecifiedInFullBackupRequest() throws Exception {
    TheBackupInterface backup = mock(TheBackupInterface.class);
    RequestContext ctx = new RequestContext(0, 1, 0, -1, 12);
    @SuppressWarnings("unchecked") TargetCaller<TheBackupInterface, Void> targetCaller = (TargetCaller<TheBackupInterface, Void>) BackupRequestType.FULL_BACKUP.getTargetCaller();
    targetCaller.call(backup, ctx, EMPTY_BUFFER, null);
    verify(backup).fullBackup(any(StoreWriter.class), eq(false));
}
Also used : StoreWriter(org.neo4j.com.storecopy.StoreWriter) TargetCaller(org.neo4j.com.TargetCaller) RequestContext(org.neo4j.com.RequestContext) Test(org.junit.Test)

Example 12 with RequestContext

use of org.neo4j.com.RequestContext in project neo4j by neo4j.

the class SlaveLocksClient method acquireSharedOnMaster.

private void acquireSharedOnMaster(ResourceType resourceType, long... resourceIds) {
    if (resourceType == ResourceTypes.NODE || resourceType == ResourceTypes.RELATIONSHIP || resourceType == ResourceTypes.GRAPH_PROPS || resourceType == ResourceTypes.LEGACY_INDEX) {
        makeSureTxHasBeenInitialized();
        RequestContext requestContext = newRequestContextFor(this);
        try (Response<LockResult> response = master.acquireSharedLock(requestContext, resourceType, resourceIds)) {
            receiveLockResponse(response);
        } catch (ComException e) {
            throw new DistributedLockFailureException("Cannot get shared lock(s) on master", master, e);
        }
    }
}
Also used : ComException(org.neo4j.com.ComException) RequestContext(org.neo4j.com.RequestContext)

Example 13 with RequestContext

use of org.neo4j.com.RequestContext in project neo4j by neo4j.

the class MasterClient214 method allocateIds.

@Override
public Response<IdAllocation> allocateIds(RequestContext context, final IdType idType) {
    Serializer serializer = buffer -> buffer.writeByte(idType.ordinal());
    Deserializer<IdAllocation> deserializer = (buffer, temporaryBuffer) -> readIdAllocation(buffer);
    return sendRequest(requestTypes.type(HaRequestTypes.Type.ALLOCATE_IDS), context, serializer, deserializer);
}
Also used : VOID_DESERIALIZER(org.neo4j.com.Protocol.VOID_DESERIALIZER) StoreId(org.neo4j.kernel.impl.store.StoreId) IdAllocation(org.neo4j.kernel.ha.id.IdAllocation) RequestType(org.neo4j.com.RequestType) LockResult(org.neo4j.kernel.ha.lock.LockResult) ObjectSerializer(org.neo4j.com.ObjectSerializer) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) ResourceType(org.neo4j.storageengine.api.lock.ResourceType) Exceptions(org.neo4j.helpers.Exceptions) StoreWriter(org.neo4j.com.storecopy.StoreWriter) LogProvider(org.neo4j.logging.LogProvider) Serializer(org.neo4j.com.Serializer) HandshakeResult(org.neo4j.kernel.ha.com.master.HandshakeResult) IdRange(org.neo4j.kernel.impl.store.id.IdRange) RequestContext(org.neo4j.com.RequestContext) RequestMonitor(org.neo4j.com.monitor.RequestMonitor) ReadableClosablePositionAwareChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel) INTERNAL_PROTOCOL_VERSION(org.neo4j.com.ProtocolVersion.INTERNAL_PROTOCOL_VERSION) MasterClient(org.neo4j.kernel.ha.com.slave.MasterClient) ByteCounterMonitor(org.neo4j.kernel.monitoring.ByteCounterMonitor) Client(org.neo4j.com.Client) EMPTY_SERIALIZER(org.neo4j.com.Protocol.EMPTY_SERIALIZER) Response(org.neo4j.com.Response) Protocol(org.neo4j.com.Protocol) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) LogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader) IOException(java.io.IOException) Protocol214(org.neo4j.com.Protocol214) MasterServer(org.neo4j.kernel.ha.com.master.MasterServer) LockStatus(org.neo4j.kernel.ha.lock.LockStatus) String.format(java.lang.String.format) IdType(org.neo4j.kernel.impl.store.id.IdType) ResponseUnpacker(org.neo4j.com.storecopy.ResponseUnpacker) Protocol.writeString(org.neo4j.com.Protocol.writeString) ProtocolVersion(org.neo4j.com.ProtocolVersion) Protocol.readString(org.neo4j.com.Protocol.readString) Deserializer(org.neo4j.com.Deserializer) Master(org.neo4j.kernel.ha.com.master.Master) IdAllocation(org.neo4j.kernel.ha.id.IdAllocation) ObjectSerializer(org.neo4j.com.ObjectSerializer) Serializer(org.neo4j.com.Serializer)

Example 14 with RequestContext

use of org.neo4j.com.RequestContext in project neo4j by neo4j.

the class MasterClient214 method createRelationshipType.

@Override
public Response<Integer> createRelationshipType(RequestContext context, final String name) {
    Serializer serializer = buffer -> writeString(buffer, name);
    Deserializer<Integer> deserializer = (buffer, temporaryBuffer) -> buffer.readInt();
    return sendRequest(requestTypes.type(HaRequestTypes.Type.CREATE_RELATIONSHIP_TYPE), context, serializer, deserializer);
}
Also used : VOID_DESERIALIZER(org.neo4j.com.Protocol.VOID_DESERIALIZER) StoreId(org.neo4j.kernel.impl.store.StoreId) IdAllocation(org.neo4j.kernel.ha.id.IdAllocation) RequestType(org.neo4j.com.RequestType) LockResult(org.neo4j.kernel.ha.lock.LockResult) ObjectSerializer(org.neo4j.com.ObjectSerializer) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) ResourceType(org.neo4j.storageengine.api.lock.ResourceType) Exceptions(org.neo4j.helpers.Exceptions) StoreWriter(org.neo4j.com.storecopy.StoreWriter) LogProvider(org.neo4j.logging.LogProvider) Serializer(org.neo4j.com.Serializer) HandshakeResult(org.neo4j.kernel.ha.com.master.HandshakeResult) IdRange(org.neo4j.kernel.impl.store.id.IdRange) RequestContext(org.neo4j.com.RequestContext) RequestMonitor(org.neo4j.com.monitor.RequestMonitor) ReadableClosablePositionAwareChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel) INTERNAL_PROTOCOL_VERSION(org.neo4j.com.ProtocolVersion.INTERNAL_PROTOCOL_VERSION) MasterClient(org.neo4j.kernel.ha.com.slave.MasterClient) ByteCounterMonitor(org.neo4j.kernel.monitoring.ByteCounterMonitor) Client(org.neo4j.com.Client) EMPTY_SERIALIZER(org.neo4j.com.Protocol.EMPTY_SERIALIZER) Response(org.neo4j.com.Response) Protocol(org.neo4j.com.Protocol) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) LogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader) IOException(java.io.IOException) Protocol214(org.neo4j.com.Protocol214) MasterServer(org.neo4j.kernel.ha.com.master.MasterServer) LockStatus(org.neo4j.kernel.ha.lock.LockStatus) String.format(java.lang.String.format) IdType(org.neo4j.kernel.impl.store.id.IdType) ResponseUnpacker(org.neo4j.com.storecopy.ResponseUnpacker) Protocol.writeString(org.neo4j.com.Protocol.writeString) ProtocolVersion(org.neo4j.com.ProtocolVersion) Protocol.readString(org.neo4j.com.Protocol.readString) Deserializer(org.neo4j.com.Deserializer) Master(org.neo4j.kernel.ha.com.master.Master) ObjectSerializer(org.neo4j.com.ObjectSerializer) Serializer(org.neo4j.com.Serializer)

Example 15 with RequestContext

use of org.neo4j.com.RequestContext in project neo4j by neo4j.

the class MasterClient214 method createLabel.

@Override
public Response<Integer> createLabel(RequestContext context, final String name) {
    Serializer serializer = buffer -> writeString(buffer, name);
    Deserializer<Integer> deserializer = (buffer, temporaryBuffer) -> buffer.readInt();
    return sendRequest(requestTypes.type(HaRequestTypes.Type.CREATE_LABEL), context, serializer, deserializer);
}
Also used : VOID_DESERIALIZER(org.neo4j.com.Protocol.VOID_DESERIALIZER) StoreId(org.neo4j.kernel.impl.store.StoreId) IdAllocation(org.neo4j.kernel.ha.id.IdAllocation) RequestType(org.neo4j.com.RequestType) LockResult(org.neo4j.kernel.ha.lock.LockResult) ObjectSerializer(org.neo4j.com.ObjectSerializer) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) ResourceType(org.neo4j.storageengine.api.lock.ResourceType) Exceptions(org.neo4j.helpers.Exceptions) StoreWriter(org.neo4j.com.storecopy.StoreWriter) LogProvider(org.neo4j.logging.LogProvider) Serializer(org.neo4j.com.Serializer) HandshakeResult(org.neo4j.kernel.ha.com.master.HandshakeResult) IdRange(org.neo4j.kernel.impl.store.id.IdRange) RequestContext(org.neo4j.com.RequestContext) RequestMonitor(org.neo4j.com.monitor.RequestMonitor) ReadableClosablePositionAwareChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel) INTERNAL_PROTOCOL_VERSION(org.neo4j.com.ProtocolVersion.INTERNAL_PROTOCOL_VERSION) MasterClient(org.neo4j.kernel.ha.com.slave.MasterClient) ByteCounterMonitor(org.neo4j.kernel.monitoring.ByteCounterMonitor) Client(org.neo4j.com.Client) EMPTY_SERIALIZER(org.neo4j.com.Protocol.EMPTY_SERIALIZER) Response(org.neo4j.com.Response) Protocol(org.neo4j.com.Protocol) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) LogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader) IOException(java.io.IOException) Protocol214(org.neo4j.com.Protocol214) MasterServer(org.neo4j.kernel.ha.com.master.MasterServer) LockStatus(org.neo4j.kernel.ha.lock.LockStatus) String.format(java.lang.String.format) IdType(org.neo4j.kernel.impl.store.id.IdType) ResponseUnpacker(org.neo4j.com.storecopy.ResponseUnpacker) Protocol.writeString(org.neo4j.com.Protocol.writeString) ProtocolVersion(org.neo4j.com.ProtocolVersion) Protocol.readString(org.neo4j.com.Protocol.readString) Deserializer(org.neo4j.com.Deserializer) Master(org.neo4j.kernel.ha.com.master.Master) ObjectSerializer(org.neo4j.com.ObjectSerializer) Serializer(org.neo4j.com.Serializer)

Aggregations

RequestContext (org.neo4j.com.RequestContext)38 Test (org.junit.Test)21 Config (org.neo4j.kernel.configuration.Config)13 SPI (org.neo4j.kernel.ha.com.master.MasterImpl.SPI)12 Response (org.neo4j.com.Response)10 LockResult (org.neo4j.kernel.ha.lock.LockResult)10 StoreId (org.neo4j.kernel.impl.store.StoreId)9 IOException (java.io.IOException)8 StoreWriter (org.neo4j.com.storecopy.StoreWriter)8 DefaultConversationSPI (org.neo4j.kernel.ha.cluster.DefaultConversationSPI)8 MasterClient (org.neo4j.kernel.ha.com.slave.MasterClient)8 Client (org.neo4j.kernel.impl.locking.Locks.Client)8 TransactionRepresentation (org.neo4j.kernel.impl.transaction.TransactionRepresentation)8 ResponseUnpacker (org.neo4j.com.storecopy.ResponseUnpacker)7 HandshakeResult (org.neo4j.kernel.ha.com.master.HandshakeResult)7 Master (org.neo4j.kernel.ha.com.master.Master)7 RequestMonitor (org.neo4j.com.monitor.RequestMonitor)6 ReadableClosablePositionAwareChannel (org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel)6 String.format (java.lang.String.format)5 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)4