Package com.orientechnologies.orient.enterprise.channel.binary

Examples of com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryClient


    do {

      try {

        final OChannelBinaryClient network = beginRequest(OChannelBinaryProtocol.REQUEST_DATASEGMENT_ADD);
        try {
          network.writeString(iSegmentName).writeString(iSegmentFileName);
        } finally {
          endRequest(network);
        }

        try {
          beginResponse(network);
          return network.readShort();
        } finally {
          endResponse(network);
        }

      } catch (Exception e) {
View Full Code Here


    do {

      try {
        final ORID rid = iRecord.getIdentity();

        final OChannelBinaryClient network = beginRequest(OChannelBinaryProtocol.REQUEST_INDEX_PUT);
        try {
          network.writeString(iKey);
          network.writeByte(iRecord.getRecordType());
          network.writeRID(rid);
        } finally {
          endRequest(network);
        }

        try {
View Full Code Here

    do {

      try {

        final OChannelBinaryClient network = beginRequest(OChannelBinaryProtocol.REQUEST_INDEX_LOOKUP);
        try {
          network.writeString(iKey);
        } finally {
          endRequest(network);
        }

        try {
View Full Code Here

    checkConnection();

    do {
      try {

        final OChannelBinaryClient network = beginRequest(OChannelBinaryProtocol.REQUEST_INDEX_REMOVE);
        try {
          network.writeString(iKey.toString());
        } finally {
          endRequest(network);
        }

        try {
View Full Code Here

    do {

      try {

        final OChannelBinaryClient network = beginRequest(OChannelBinaryProtocol.REQUEST_INDEX_SIZE);
        endRequest(network);

        try {
          beginResponse(network);
          return network.readInt();
        } finally {
          endResponse(network);
        }

      } catch (Exception e) {
View Full Code Here

    checkConnection();

    do {
      try {

        final OChannelBinaryClient network = beginRequest(OChannelBinaryProtocol.REQUEST_INDEX_KEYS);
        endRequest(network);

        try {
          beginResponse(network);
          return network.readStringSet();
        } finally {
          endResponse(network);
        }

      } catch (Exception e) {
View Full Code Here

  }

  protected void openRemoteDatabase(final String iUserName, final String iUserPassword) throws IOException {
    createConnectionPool();

    final OChannelBinaryClient network = beginRequest(OChannelBinaryProtocol.REQUEST_DB_OPEN);
    try {
      network.writeString(name).writeString(iUserName).writeString(iUserPassword);
    } finally {
      endRequest(network);
    }

    try {
      beginResponse(network);

      final int sessionId = network.readInt();
      setSessionId(sessionId);

      OLogManager.instance().debug(null, "Client connected with session id: " + sessionId);

      int tot = network.readInt();
      String clusterName;
      for (int i = 0; i < tot; ++i) {
        clusterName = network.readString().toLowerCase();
        clustersIds.put(clusterName, network.readInt());
        clustersTypes.put(clusterName, network.readString());
      }

      // READ CLUSTER CONFIGURATION
      updateClusterConfiguration(network.readBytes());

    } finally {
      endResponse(network);
    }
View Full Code Here

    for (OPair<String, String[]> server : serverURLs) {
      port = Integer.parseInt(server.getValue()[server.getValue().length - 1]);

      OLogManager.instance().debug(this, "Trying to connect to the remote host %s:%d...", server.getKey(), port);
      try {
        final OChannelBinaryClient network = new OChannelBinaryClient(server.getKey(), port, clientConfiguration);

        OChannelBinaryProtocol.checkProtocolVersion(network);

        return network;
      } catch (Exception e) {
View Full Code Here

   * @param iCommand
   * @return
   * @throws IOException
   */
  protected OChannelBinaryClient beginRequest(final byte iCommand) throws IOException {
    OChannelBinaryClient network = null;

    // FIND THE FIRST FREE CHANNEL AVAILABLE
    final boolean locked = lock.acquireSharedLock();

    try {
      while (network == null) {
        if (networkPoolCursor >= networkPool.size())
          networkPoolCursor = 0;

        network = networkPool.get(networkPoolCursor);
        if (network.getLockWrite().tryLock())
          break;

        networkPoolCursor++;
      }
     
    } finally {
      lock.releaseSharedLock(locked);
    }

    network.writeByte(iCommand);
    network.writeInt(getSessionId());

    return network;
  }
View Full Code Here

        minPool = OGlobalConfiguration.CLIENT_CHANNEL_MIN_POOL.getValueAsInteger();
        maxPool = OGlobalConfiguration.CLIENT_CHANNEL_MAX_POOL.getValueAsInteger();

        // CONNECT TO THE SERVER
        final OChannelBinaryClient firstChannel = createNetworkConnection();
        networkPool.add(firstChannel);
        serviceThread = new OStorageRemoteServiceThread(new OStorageRemoteThread(this), firstChannel);

        for (int i = 1; i < minPool; ++i)
          networkPool.add(createNetworkConnection());
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryClient

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.