Search in sources :

Example 6 with Iv2InitiateTaskMessage

use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.

the class TestTransactionTaskQueue method createSpProc.

// Cases to test:
// several single part txns
private SpProcedureTask createSpProc(long localTxnId, TransactionTaskQueue queue) {
    // Mock an initiate message; override its txnid to return
    // the default SP value (usually set by ClientInterface).
    Iv2InitiateTaskMessage init = mock(Iv2InitiateTaskMessage.class);
    when(init.getTxnId()).thenReturn(Iv2InitiateTaskMessage.UNUSED_MP_TXNID);
    when(init.getSpHandle()).thenReturn(localTxnId);
    InitiatorMailbox mbox = mock(InitiatorMailbox.class);
    when(mbox.getHSId()).thenReturn(1337l);
    SpProcedureTask task = new SpProcedureTask(mbox, "TestProc", queue, init);
    return task;
}
Also used : Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage)

Example 7 with Iv2InitiateTaskMessage

use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.

the class TestSpSchedulerDedupe method createMsg.

private Iv2InitiateTaskMessage createMsg(long txnId, boolean readOnly, boolean singlePart, long destHSId) {
    // Mock an invocation for MockSPName.
    StoredProcedureInvocation spi = mock(StoredProcedureInvocation.class);
    when(spi.getProcName()).thenReturn(MockSPName);
    ParameterSet bleh = mock(ParameterSet.class);
    when(spi.getParams()).thenReturn(bleh);
    Iv2InitiateTaskMessage task = new // initHSID
    Iv2InitiateTaskMessage(// initHSID
    destHSId, // coordHSID
    Long.MIN_VALUE, // truncationHandle
    txnId - 1, // txnId
    txnId, // uniqueID
    UniqueIdGenerator.makeIdFromComponents(System.currentTimeMillis(), 0, 0), // readonly
    readOnly, // single-part
    singlePart, // invocation
    spi, // client interface handle
    Long.MAX_VALUE, // connectionId
    Long.MAX_VALUE, // isForReplay
    false);
    // sp: sphandle == txnid
    task.setTxnId(txnId);
    task.setSpHandle(txnId);
    return task;
}
Also used : ParameterSet(org.voltdb.ParameterSet) StoredProcedureInvocation(org.voltdb.StoredProcedureInvocation) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage)

Example 8 with Iv2InitiateTaskMessage

use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.

the class TestSpSchedulerDedupe method testReplicaInitiateTaskResponseShortCircuitRead.

@Test
public void testReplicaInitiateTaskResponseShortCircuitRead() throws Exception {
    // replica does not receive reads on SAFE mode, except for FAST mode
    m_readLevel = Consistency.ReadLevel.FAST;
    long txnid = TxnEgo.makeZero(0).getTxnId();
    createObjs();
    Iv2InitiateTaskMessage sptask = createMsg(txnid, true, true, dut_hsid);
    sptask.setSpHandle(txnid);
    dut.deliver(sptask);
    // verify no response sent yet
    verify(mbox, times(0)).send(anyLong(), (VoltMessage) anyObject());
    verify(mbox, times(0)).send(new long[] { anyLong() }, (VoltMessage) anyObject());
    InitiateResponseMessage resp = new InitiateResponseMessage(sptask);
    dut.deliver(resp);
    verify(mbox, times(1)).send(eq(dut_hsid), eq(resp));
    m_readLevel = Consistency.ReadLevel.SAFE;
}
Also used : Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) InitiateResponseMessage(org.voltdb.messaging.InitiateResponseMessage) Test(org.junit.Test)

Example 9 with Iv2InitiateTaskMessage

use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.

the class TestReplaySequencer method makeIv2InitTask.

TransactionInfoBaseMessage makeIv2InitTask(long unused, String procName) {
    Iv2InitiateTaskMessage m = mock(Iv2InitiateTaskMessage.class);
    StoredProcedureInvocation invocation = mock(StoredProcedureInvocation.class);
    when(invocation.getProcName()).thenReturn(procName);
    when(m.getStoredProcedureInvocation()).thenReturn(invocation);
    when(m.isForReplay()).thenReturn(true);
    return m;
}
Also used : StoredProcedureInvocation(org.voltdb.StoredProcedureInvocation) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage)

Example 10 with Iv2InitiateTaskMessage

use of org.voltdb.messaging.Iv2InitiateTaskMessage in project voltdb by VoltDB.

the class ProcedureRunnerNT method callAllNodeNTProcedure.

/**
     * Send an invocation directly to each host's CI mailbox.
     * This ONLY works for NT procedures.
     * Track responses and complete the returned future when they're all accounted for.
     */
protected CompletableFuture<Map<Integer, ClientResponse>> callAllNodeNTProcedure(String procName, Object... params) {
    // only one of these at a time
    if (m_outstandingAllHostProc.get()) {
        throw new VoltAbortException(new IllegalStateException("Only one AllNodeNTProcedure operation can be running at a time."));
    }
    m_outstandingAllHostProc.set(true);
    StoredProcedureInvocation invocation = new StoredProcedureInvocation();
    invocation.setProcName(procName);
    invocation.setParams(params);
    invocation.setClientHandle(m_id);
    final Iv2InitiateTaskMessage workRequest = new Iv2InitiateTaskMessage(m_mailbox.getHSId(), m_mailbox.getHSId(), Iv2InitiateTaskMessage.UNUSED_TRUNC_HANDLE, m_id, m_id, true, false, invocation, m_id, ClientInterface.NT_REMOTE_PROC_CID, false);
    m_allHostFut = new CompletableFuture<>();
    m_allHostResponses = new HashMap<>();
    Set<Integer> liveHostIds = null;
    // also held when
    synchronized (m_allHostCallbackLock) {
        // collect the set of live client interface mailbox ids
        liveHostIds = VoltDB.instance().getHostMessenger().getLiveHostIds();
        m_outstandingAllHostProcedureHostIds = liveHostIds;
    }
    // convert host ids to hsids
    long[] hsids = liveHostIds.stream().map(hostId -> CoreUtils.getHSIdFromHostAndSite(hostId, HostMessenger.CLIENT_INTERFACE_SITE_ID)).mapToLong(x -> x).toArray();
    //  you get a concurrent modification exception
    for (long hsid : hsids) {
        m_mailbox.send(hsid, workRequest);
    }
    return m_allHostFut;
}
Also used : VoltAbortException(org.voltdb.VoltProcedure.VoltAbortException) Set(java.util.Set) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) ClientResponse(org.voltdb.client.ClientResponse) InvocationTargetException(java.lang.reflect.InvocationTargetException) ExecutionException(java.util.concurrent.ExecutionException) HostMessenger(org.voltcore.messaging.HostMessenger) Connection(org.voltcore.network.Connection) Mailbox(org.voltcore.messaging.Mailbox) InitiateResponseMessage(org.voltdb.messaging.InitiateResponseMessage) SerializableException(org.voltdb.exceptions.SerializableException) Map(java.util.Map) CoreUtils(org.voltcore.utils.CoreUtils) AuthUser(org.voltdb.AuthSystem.AuthUser) ProcedureCallback(org.voltdb.client.ProcedureCallback) Method(java.lang.reflect.Method) ExecutorService(java.util.concurrent.ExecutorService) VoltLogger(org.voltcore.logging.VoltLogger) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) VoltAbortException(org.voltdb.VoltProcedure.VoltAbortException)

Aggregations

Iv2InitiateTaskMessage (org.voltdb.messaging.Iv2InitiateTaskMessage)40 Test (org.junit.Test)14 StoredProcedureInvocation (org.voltdb.StoredProcedureInvocation)13 Mailbox (org.voltcore.messaging.Mailbox)8 FragmentTaskMessage (org.voltdb.messaging.FragmentTaskMessage)8 InitiateResponseMessage (org.voltdb.messaging.InitiateResponseMessage)8 ArrayList (java.util.ArrayList)7 CompleteTransactionMessage (org.voltdb.messaging.CompleteTransactionMessage)7 SiteProcedureConnection (org.voltdb.SiteProcedureConnection)6 FragmentResponseMessage (org.voltdb.messaging.FragmentResponseMessage)6 List (java.util.List)5 Iv2RepairLogResponseMessage (org.voltdb.messaging.Iv2RepairLogResponseMessage)5 Matchers.anyLong (org.mockito.Matchers.anyLong)4 ExecutionException (java.util.concurrent.ExecutionException)3 TransactionInfoBaseMessage (org.voltcore.messaging.TransactionInfoBaseMessage)3 ClientResponseImpl (org.voltdb.ClientResponseImpl)3 ParameterSet (org.voltdb.ParameterSet)3 VoltTable (org.voltdb.VoltTable)3 VoltTrace (org.voltdb.utils.VoltTrace)3 HashMap (java.util.HashMap)2