Package com.orientechnologies.orient.server.distributed

Examples of com.orientechnologies.orient.server.distributed.ODistributedRequest


        restoringMessages = false;
        break;
      }

      String senderNode = null;
      ODistributedRequest message = null;
      try {
        message = readRequest();

        if (message != null) {
          // DECIDE TO USE THE HZ MAP ONLY IF THE COMMAND IS NOT IDEMPOTENT (ALL BUT READ-RECORD/SQL SELECT/SQL TRAVERSE
          // final boolean saveAsPending = !message.getTask().isIdempotent();
          // if (saveAsPending)
          // SAVE THE MESSAGE IN TO THE UNDO MAP IN CASE OF FAILURE
          // lastPendingMessagesMap.put(databaseName, message);

          senderNode = message.getSenderNodeName();
          onMessage(message);

          // if (saveAsPending)
          // OK: REMOVE THE UNDO BUFFER
          // lastPendingMessagesMap.remove(databaseName);
        }

      } catch (InterruptedException e) {
        // EXIT CURRENT THREAD
        Thread.interrupted();
        break;
      } catch (DistributedObjectDestroyedException e) {
        Thread.interrupted();
        break;
      } catch (HazelcastInstanceNotActiveException e) {
        Thread.interrupted();
        break;
      } catch (HazelcastException e) {
        if (e.getCause() instanceof InterruptedException)
          Thread.interrupted();
        else
          ODistributedServerLog.error(this, manager.getLocalNodeName(), senderNode, DIRECTION.IN,
              "error on executing distributed request %d: %s", e, message != null ? message.getId() : -1,
              message != null ? message.getTask() : "-");
      } catch (Throwable e) {
        ODistributedServerLog.error(this, getLocalNodeName(), senderNode, DIRECTION.IN,
            "error on executing distributed request %d: %s", e, message != null ? message.getId() : -1,
            message != null ? message.getTask() : "-");
      }
    }

    ODistributedServerLog.debug(this, manager.getLocalNodeName(), null, DIRECTION.NONE, "end of reading requests for database %s",
        databaseName);
View Full Code Here


    return database;
  }

  protected ODistributedRequest readRequest() throws InterruptedException {
    // GET FROM DISTRIBUTED QUEUE. IF EMPTY WAIT FOR A MESSAGE
    ODistributedRequest req = nextMessage();

    while (distributed.waitForMessageId.get() > -1) {
      if (req != null) {
        if (req.getId() >= distributed.waitForMessageId.get()) {
          // ARRIVED, RESET IT
          ODistributedServerLog.debug(this, manager.getLocalNodeName(), req.getSenderNodeName(), DIRECTION.IN,
              "reached waited request %d on request=%s sourceNode=%s", distributed.waitForMessageId.get(), req,
              req.getSenderNodeName());

          distributed.waitForMessageId.set(-1);
          break;
        } else {
          // SKIP IT
          ODistributedServerLog.debug(this, manager.getLocalNodeName(), req.getSenderNodeName(), DIRECTION.IN,
              "discarded request %d because waiting for %d request=%s sourceNode=%s", req.getId(),
              distributed.waitForMessageId.get(), req, req.getSenderNodeName());

          // READ THE NEXT ONE
          req = nextMessage();
        }
      }
    }

    if (ODistributedServerLog.isDebugEnabled())
      ODistributedServerLog.debug(this, manager.getLocalNodeName(), req.getSenderNodeName(), DIRECTION.IN,
          "processing request=%s sourceNode=%s", req, req.getSenderNodeName());

    return req;
  }
View Full Code Here

  protected IMap<String, Object> restoreMessagesBeforeFailure(final boolean iRestoreMessages) {
    final IMap<String, Object> lastPendingRequestMap = manager.getHazelcastInstance().getMap(getPendingRequestMapName());
    if (iRestoreMessages) {
      // RESTORE LAST UNDO MESSAGE
      final ODistributedRequest lastPendingRequest = (ODistributedRequest) lastPendingRequestMap.remove(databaseName);
      if (lastPendingRequest != null) {
        // RESTORE LAST REQUEST
        ODistributedServerLog.warn(this, getLocalNodeName(), null, DIRECTION.NONE,
            "restore last replication message before the crash for database '%s': %s...", databaseName, lastPendingRequest);

        try {
          initDatabaseInstance();

          final boolean executeLastPendingRequest = checkIfOperationHasBeenExecuted(lastPendingRequest,
              lastPendingRequest.getTask());

          if (executeLastPendingRequest)
            onMessage(lastPendingRequest);

        } catch (Throwable t) {
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.server.distributed.ODistributedRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.