/**
     * Check if flags in correct state.
     *
     * @param msg Message.
     */
    private void checkSyncFlags(GridIoMessage msg) {
      if (!commSpiEnabled) return;

      Object o = msg.message();

      if (!(o instanceof GridDistributedLockRequest)) return;

      GridKernal g = (GridKernal) G.grid(nodeId);

      GridCacheTxManager<Object, Object> tm =
          g.internalCache(REPLICATED_ASYNC_CACHE_NAME).context().tm();

      GridCacheVersion v = ((GridCacheVersionable) o).version();

      GridCacheTxEx t = tm.tx(v);

      if (t.hasWriteKey("x1")) {
        assertFalse(t.syncCommit());
      } else if (t.hasWriteKey("x2")) {
        assertTrue(t.syncCommit());
      } else if (t.hasWriteKey("x3")) {
        assertFalse(t.syncCommit());
      } else if (t.hasWriteKey("x4")) {
        assertTrue(t.syncCommit());
      }
    }
    /**
     * Send message optionally either blocking it or throwing an exception if it is of {@link
     * GridJobExecuteResponse} type.
     *
     * @param node Destination node.
     * @param msg Message to be sent.
     * @throws GridSpiException If failed.
     */
    private void sendMessage0(GridNode node, GridTcpCommunicationMessageAdapter msg)
        throws GridSpiException {
      if (msg instanceof GridIoMessage) {
        GridIoMessage msg0 = (GridIoMessage) msg;

        if (msg0.message() instanceof GridJobExecuteResponse) {
          respLatch.countDown();

          if (wait) {
            try {
              U.await(waitLatch);
            } catch (GridInterruptedException ignore) {
              // No-op.
            }
          }
        }
      }

      if (!block) super.sendMessage(node, msg);
    }