Search in sources :

Example 21 with ClientResponseImpl

use of org.voltdb.ClientResponseImpl in project voltdb by VoltDB.

the class SpScheduler method sequenceForReplay.

/**
     * Sequence the message for replay if it's for CL or DR.
     *
     * @param message
     * @return true if the message can be delivered directly to the scheduler,
     * false if the message is queued
     */
@Override
public boolean sequenceForReplay(VoltMessage message) {
    boolean canDeliver = false;
    long sequenceWithUniqueId = Long.MIN_VALUE;
    boolean commandLog = (message instanceof TransactionInfoBaseMessage && (((TransactionInfoBaseMessage) message).isForReplay()));
    boolean sentinel = message instanceof MultiPartitionParticipantMessage;
    boolean replay = commandLog || sentinel;
    boolean sequenceForReplay = m_isLeader && replay;
    if (replay) {
        sequenceWithUniqueId = ((TransactionInfoBaseMessage) message).getUniqueId();
    }
    if (sequenceForReplay) {
        InitiateResponseMessage dupe = m_replaySequencer.dedupe(sequenceWithUniqueId, (TransactionInfoBaseMessage) message);
        if (dupe != null) {
            // Duplicate initiate task message, send response
            m_mailbox.send(dupe.getInitiatorHSId(), dupe);
        } else if (!m_replaySequencer.offer(sequenceWithUniqueId, (TransactionInfoBaseMessage) message)) {
            canDeliver = true;
        } else {
            deliverReadyTxns();
        }
        // If it's a DR sentinel, send an acknowledgement
        if (sentinel && !commandLog) {
            MultiPartitionParticipantMessage mppm = (MultiPartitionParticipantMessage) message;
            final InitiateResponseMessage response = new InitiateResponseMessage(mppm);
            ClientResponseImpl clientResponse = new ClientResponseImpl(ClientResponseImpl.UNEXPECTED_FAILURE, new VoltTable[0], ClientResponseImpl.IGNORED_TRANSACTION);
            response.setResults(clientResponse);
            m_mailbox.send(response.getInitiatorHSId(), response);
        }
    } else {
        if (replay) {
            // Update last seen and last polled uniqueId for replicas
            m_replaySequencer.updateLastSeenUniqueId(sequenceWithUniqueId, (TransactionInfoBaseMessage) message);
            m_replaySequencer.updateLastPolledUniqueId(sequenceWithUniqueId, (TransactionInfoBaseMessage) message);
        }
        canDeliver = true;
    }
    return canDeliver;
}
Also used : MultiPartitionParticipantMessage(org.voltdb.messaging.MultiPartitionParticipantMessage) TransactionInfoBaseMessage(org.voltcore.messaging.TransactionInfoBaseMessage) InitiateResponseMessage(org.voltdb.messaging.InitiateResponseMessage) ClientResponseImpl(org.voltdb.ClientResponseImpl)

Example 22 with ClientResponseImpl

use of org.voltdb.ClientResponseImpl in project voltdb by VoltDB.

the class InitiateResponseMessage method initFromBuffer.

@Override
public void initFromBuffer(ByteBuffer buf) throws IOException {
    m_txnId = buf.getLong();
    m_spHandle = buf.getLong();
    m_initiatorHSId = buf.getLong();
    m_coordinatorHSId = buf.getLong();
    m_clientInterfaceHandle = buf.getLong();
    m_connectionId = buf.getLong();
    m_readOnly = buf.get() == 1;
    m_recovering = buf.get() == 1;
    m_mispartitioned = buf.get() == 1;
    m_response = new ClientResponseImpl();
    m_response.initFromBuffer(buf);
    m_commit = (m_response.getStatus() == ClientResponseImpl.SUCCESS);
    if (m_mispartitioned) {
        long hashinatorVersion = buf.getLong();
        byte[] hashinatorBytes = new byte[buf.getInt()];
        buf.get(hashinatorBytes);
        m_currentHashinatorConfig = Pair.of(hashinatorVersion, hashinatorBytes);
        // SPI must be the last to deserialize, it will take the remaining as parameter bytes
        m_invocation = new StoredProcedureInvocation();
        m_invocation.initFromBuffer(buf);
        m_commit = false;
    }
}
Also used : StoredProcedureInvocation(org.voltdb.StoredProcedureInvocation) ClientResponseImpl(org.voltdb.ClientResponseImpl)

Example 23 with ClientResponseImpl

use of org.voltdb.ClientResponseImpl in project voltdb by VoltDB.

the class UpdateApplicationBase method makeQuickResponse.

/** Error generating shortcut method */
protected static CompletableFuture<ClientResponse> makeQuickResponse(byte statusCode, String msg) {
    ClientResponseImpl cri = new ClientResponseImpl(statusCode, new VoltTable[0], msg);
    CompletableFuture<ClientResponse> f = new CompletableFuture<>();
    f.complete(cri);
    return f;
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) CompletableFuture(java.util.concurrent.CompletableFuture) ClientResponseImpl(org.voltdb.ClientResponseImpl)

Example 24 with ClientResponseImpl

use of org.voltdb.ClientResponseImpl in project voltdb by VoltDB.

the class TestVoltMessageSerialization method testInvalidTableCount.

public void testInvalidTableCount() throws Exception {
    int size = // version
    1 + // clientHandle
    8 + // present fields
    1 + // status
    1 + // app status
    1 + // cluster roundtrip time
    4 + // number of result tables
    2;
    ByteBuffer buf = ByteBuffer.allocate(size);
    //version
    buf.put((byte) 0);
    buf.putLong(1L);
    byte presentFields = 0;
    buf.put(presentFields);
    buf.put(ClientResponse.SUCCESS);
    buf.put(ClientResponse.SUCCESS);
    buf.putInt(100);
    buf.putShort((short) (Short.MAX_VALUE + 1));
    buf.flip();
    ClientResponseImpl deserialized = new ClientResponseImpl();
    try {
        deserialized.initFromBuffer(buf);
        fail("Must have failed for invalid table count");
    } catch (IOException e) {
        assertTrue(e.getMessage().contains("is negative"));
    }
}
Also used : ClientResponseImpl(org.voltdb.ClientResponseImpl) IOException(java.io.IOException) ByteBuffer(java.nio.ByteBuffer)

Example 25 with ClientResponseImpl

use of org.voltdb.ClientResponseImpl in project voltdb by VoltDB.

the class TestVoltMessageSerialization method testInitiateResponseForIv2.

public void testInitiateResponseForIv2() throws IOException {
    StoredProcedureInvocation spi = new StoredProcedureInvocation();
    spi.setClientHandle(25);
    spi.setProcName("elmerfudd");
    spi.setParams(57, "wrascallywabbit");
    Iv2InitiateTaskMessage itask = new Iv2InitiateTaskMessage(23, 8, 10L, 100045, 99, true, false, spi, 2101, 3101, true);
    VoltTable table = new VoltTable(new VoltTable.ColumnInfo("foobar", VoltType.STRING));
    table.addRow("howmanylicksdoesittaketogettothecenterofatootsiepop");
    InitiateResponseMessage iresponse = new InitiateResponseMessage(itask);
    iresponse.setResults(new ClientResponseImpl(ClientResponse.GRACEFUL_FAILURE, new VoltTable[] { table, table }, "knockknockbananna"));
    iresponse.setClientHandle(99);
    InitiateResponseMessage iresponse2 = (InitiateResponseMessage) checkVoltMessage(iresponse);
    assertEquals(iresponse.getTxnId(), iresponse2.getTxnId());
    assertTrue(iresponse2.isReadOnly());
}
Also used : StoredProcedureInvocation(org.voltdb.StoredProcedureInvocation) ClientResponseImpl(org.voltdb.ClientResponseImpl) VoltTable(org.voltdb.VoltTable)

Aggregations

ClientResponseImpl (org.voltdb.ClientResponseImpl)32 VoltTable (org.voltdb.VoltTable)20 IOException (java.io.IOException)10 ClientResponse (org.voltdb.client.ClientResponse)10 InitiateResponseMessage (org.voltdb.messaging.InitiateResponseMessage)7 CompletableFuture (java.util.concurrent.CompletableFuture)5 StoredProcedureInvocation (org.voltdb.StoredProcedureInvocation)4 ProcCallException (org.voltdb.client.ProcCallException)4 Client (org.voltdb.client.Client)3 NoConnectionsException (org.voltdb.client.NoConnectionsException)3 Iv2InitiateTaskMessage (org.voltdb.messaging.Iv2InitiateTaskMessage)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 CatalogContext (org.voltdb.CatalogContext)2 ServerThread (org.voltdb.ServerThread)2 TableHelper (org.voltdb.TableHelper)2 VoltDB (org.voltdb.VoltDB)2 Configuration (org.voltdb.VoltDB.Configuration)2 Database (org.voltdb.catalog.Database)2