use of org.voltdb.StoredProcedureInvocation in project voltdb by VoltDB.
the class MiscUtils method roundTripForCL.
/**
* Serialize and then deserialize an invocation so that it has serializedParams set for command logging if the
* invocation is sent to a local site.
* @return The round-tripped version of the invocation
* @throws IOException
*/
public static StoredProcedureInvocation roundTripForCL(StoredProcedureInvocation invocation) throws IOException {
if (invocation.getSerializedParams() != null) {
return invocation;
}
ByteBuffer buf = ByteBuffer.allocate(invocation.getSerializedSize());
invocation.flattenToBuffer(buf);
buf.flip();
StoredProcedureInvocation rti = new StoredProcedureInvocation();
rti.initFromBuffer(buf);
return rti;
}
use of org.voltdb.StoredProcedureInvocation 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;
}
}
use of org.voltdb.StoredProcedureInvocation in project voltdb by VoltDB.
the class InitiateTaskMessage method initFromBuffer.
@Override
public void initFromBuffer(ByteBuffer buf) throws IOException {
super.initFromBuffer(buf);
m_lastSafeTxnID = buf.getLong();
m_isSinglePartition = buf.get() == 1;
if (buf.get() == 0) {
m_nonCoordinatorSites = new long[buf.getInt()];
for (int i = 0; i < m_nonCoordinatorSites.length; i++) {
m_nonCoordinatorSites[i] = buf.getLong();
}
}
m_invocation = new StoredProcedureInvocation();
m_invocation.initFromBuffer(buf);
}
use of org.voltdb.StoredProcedureInvocation in project voltdb by VoltDB.
the class TestVoltMessageSerialization method testInitiateTask.
public void testInitiateTask() throws IOException {
StoredProcedureInvocation spi = new StoredProcedureInvocation();
spi.setClientHandle(25);
spi.setProcName("johnisgreat");
spi.setParams(57, "gooniestoo", "dudemandude");
InitiateTaskMessage itask = new InitiateTaskMessage(23, 8, 100045, true, false, spi, 2101);
InitiateTaskMessage itask2 = (InitiateTaskMessage) checkVoltMessage(itask);
assertEquals(itask.getInitiatorHSId(), itask2.getInitiatorHSId());
assertEquals(itask.getTxnId(), itask2.getTxnId());
assertEquals(itask.isReadOnly(), itask2.isReadOnly());
assertEquals(itask.isSinglePartition(), itask2.isSinglePartition());
assertEquals(itask.getStoredProcedureName(), itask2.getStoredProcedureName());
assertEquals(itask.getParameterCount(), itask2.getParameterCount());
assertEquals(itask.getLastSafeTxnId(), itask2.getLastSafeTxnId());
}
use of org.voltdb.StoredProcedureInvocation in project voltdb by VoltDB.
the class TestVoltMessageSerialization method testIv2RepairLogResponseMessage.
public void testIv2RepairLogResponseMessage() throws Exception {
// make a first itask
StoredProcedureInvocation spi = new StoredProcedureInvocation();
spi.setClientHandle(25);
spi.setProcName("johnisgreat");
spi.setParams(57, "gooniestoo", "dudemandude");
Iv2InitiateTaskMessage itask = new Iv2InitiateTaskMessage(23, 8, 100044, 100045, 99, true, false, spi, 2101, 3101, false);
itask.setSpHandle(31337);
Iv2RepairLogResponseMessage r1 = new Iv2RepairLogResponseMessage(0, 1, 2, 3L, 3L, itask);
Iv2RepairLogResponseMessage r2 = (Iv2RepairLogResponseMessage) checkVoltMessage(r1);
assertEquals(r1.getOfTotal(), r2.getOfTotal());
assertEquals(r1.getHandle(), r2.getHandle());
assertEquals(r1.getTxnId(), r2.getTxnId());
assertEquals(r1.getRequestId(), r2.getRequestId());
assertEquals(r1.getSequence(), r2.getSequence());
assertFalse(r1.hasHashinatorConfig());
// make sure the payload was round-tripped correctly.
Iv2InitiateTaskMessage itask2 = (Iv2InitiateTaskMessage) r2.getPayload();
assertEquals(itask.getInitiatorHSId(), itask2.getInitiatorHSId());
assertEquals(itask.getTxnId(), itask2.getTxnId());
assertEquals(itask.getUniqueId(), itask2.getUniqueId());
assertEquals(itask.isReadOnly(), itask2.isReadOnly());
assertEquals(itask.isSinglePartition(), itask2.isSinglePartition());
assertEquals(itask.getStoredProcedureName(), itask2.getStoredProcedureName());
assertEquals(itask.getParameterCount(), itask2.getParameterCount());
assertEquals(itask.getClientInterfaceHandle(), itask2.getClientInterfaceHandle());
assertEquals(itask.getClientInterfaceHandle(), 2101);
assertEquals(itask.getConnectionId(), 3101);
assertEquals(itask.getSpHandle(), itask2.getSpHandle());
assertEquals(31337, itask.getSpHandle());
assertFalse(itask.isForReplay());
}
Aggregations