Examples of ODocument


Examples of com.orientechnologies.orient.core.record.impl.ODocument

      case BEFORE_DELETE:
        // CHECK IF THE CURRENT NODE IS THE OWNER FOR THAT CLUSTER
        final String clusterName = iRecord.getDatabase().getClusterNameById(iRecord.getIdentity().getClusterId());

        if (!manager.isCurrentNodeTheClusterOwner(iRecord.getDatabase().getName(), clusterName)) {
          final ODocument servers = manager.getServersForCluster(iRecord.getDatabase().getName(), clusterName);
          throw new ODistributedException("Can't apply changes to the cluster '" + clusterName
              + "' because the current node is not the owner for that record cluster. Please connect to the server: "
              + servers.field("owner"));
        }
        break;

      case AFTER_CREATE:
        manager.distributeRequest(new OTransactionRecordEntry((ORecordInternal<?>) iRecord, OTransactionRecordEntry.CREATED, null));
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ODocument

  @Override
  public void onAfterClientRequest(final OClientConnection iConnection, final byte iRequestType) {
    if (iRequestType == OChannelBinaryProtocol.REQUEST_DB_OPEN)
      try {
        final ODocument clusterConfig = getClusterConfiguration(iConnection.database.getName());
        byte[] serializedDocument = clusterConfig != null ? clusterConfig.toStream() : null;
        ((OChannelBinary) iConnection.protocol.getChannel()).writeBytes(serializedDocument);
      } catch (IOException e) {
        throw new OIOException("Error on marshalling of cluster configuration", e);
      }
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ODocument

   *          Cluster name
   * @return true if the cluster's owner for the requested node is the current one, otherwise false
   */
  public boolean isCurrentNodeTheClusterOwner(final String iDatabaseName, final String iClusterName) {
    // GET THE NODES INVOLVED IN THE UPDATE
    final ODocument servers = getServersForCluster(iDatabaseName, iClusterName);
    if (servers == null)
      // NOT DISTRIBUTED CFG
      return true;

    if (ODistributedRequesterThreadLocal.INSTANCE.get())
      return true;

    return servers.field("owner").equals(getId());

  }
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ODocument

  }

  public ODocument getServersForCluster(final String iDatabaseName, final String iClusterName) {
    // GET THE NODES INVOLVED IN THE UPDATE
    final ODocument database = clusterDbConfigurations.get(iDatabaseName);
    if (database == null)
      return null;

    final ODocument clusters = database.field("clusters");
    return (ODocument) (clusters.containsField(iClusterName) ? clusters.field(iClusterName) : clusters.field("*"));
  }
 
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ODocument

      if (nodes.isEmpty())
        return;

      // GET THE NODES INVOLVED IN THE UPDATE
      final ODocument servers = getServersForCluster(iTransactionEntry.getRecord().getDatabase().getName(),
          iTransactionEntry.clusterName);

      if (servers == null)
        return;

      nodeList = new HashMap<ODistributedServerNodeRemote, ODistributedServerNodeRemote.SYNCH_TYPE>();
      if (servers.field("synch") != null)
        for (String s : (Collection<String>) servers.field("synch")) {
          nodeList.put(nodes.get(s), ODistributedServerNodeRemote.SYNCH_TYPE.SYNCHRONOUS);
        }
      if (servers.field("asynch") != null)
        for (String s : (Collection<String>) servers.field("asynch")) {
          nodeList.put(nodes.get(s), ODistributedServerNodeRemote.SYNCH_TYPE.ASYNCHRONOUS);
        }

    } finally {
      lock.releaseSharedLock();
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ODocument

  @SuppressWarnings("unchecked")
  public ODocument addServerInConfiguration(final String iDatabaseName, final String iAddress,
      final String iServerClusterConfiguration) throws UnknownHostException {

    ODocument dbConfiguration = clusterDbConfigurations.get(iDatabaseName);
    if (dbConfiguration == null) {
      dbConfiguration = new ODocument();
      clusterDbConfigurations.put(iDatabaseName, dbConfiguration);
    }

    // ADD IT IN THE SERVER LIST
    ODocument clusters = dbConfiguration.field("clusters");
    if (clusters == null) {
      clusters = new ODocument().addOwner(dbConfiguration);
      dbConfiguration.field("clusters", clusters);
    }

    ODocument allClusters = clusters.field("*");
    if (allClusters == null) {
      allClusters = new ODocument().addOwner(clusters);
      clusters.field("*", allClusters);
    }

    // MERGE CONFIG
    final ODocument cfgDoc = new ODocument().fromJSON(iServerClusterConfiguration);

    Object fieldValue;
    for (String fieldName : cfgDoc.fieldNames()) {
      fieldValue = cfgDoc.field(fieldName);

      ODocument clusterConfig = clusters.field(fieldName);
      if (clusterConfig == null)
        // GET THE CONFIG OF THE NEW SERVER
        clusterConfig = (ODocument) fieldValue;
      else {
        // MERGE CLUSTER CONFIG
        if (fieldValue instanceof ODocument)
          clusterConfig.merge((ODocument) cfgDoc.field(fieldName), true, true);
        else
          clusterConfig.merge((Map<String, Object>) cfgDoc.field(fieldName), true, true);
      }
    }

    OLogManager.instance().warn(this, "Updated server node configuration: %s", dbConfiguration.toJSON(""));

View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ODocument

        // PUT IN TEMPORARY LIST TO GET FETCHED AFTER ALL FOR CACHE
        recordEntries.put((ORecordId) entry.getRecord().getIdentity(), entry);

      }
      remoteIndexEntries = new ODocument(channel.readBytes());

      // UNMARSHALL ALL THE RECORD AT THE END TO BE SURE ALL THE RECORD ARE LOADED IN LOCAL TX
      for (ORecord<?> record : createdRecords.values())
        unmarshallRecord(record);
      for (ORecord<?> record : updatedRecords.values())
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ODocument

        currentRecord = connection.database.load(rid);

        if (currentRecord == null)
          throw new ORecordNotFoundException(rid.toString());

        final ODocument doc = (ODocument) currentRecord;
        doc.merge((ODocument) newRecord, false, false);

      } else
        currentRecord = newRecord;

      currentRecord.setVersion(version);
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ODocument

    OSerializableStream instance = null;

    int propertyPos = iStream.indexOf(':');
    int pos = iStream.indexOf(OStreamSerializerHelper.SEPARATOR);
    if (pos < 0 || pos > propertyPos) {
      instance = new ODocument((ODatabaseRecord) iDatabase);
      pos = -1;
    } else {
      final String className = iStream.substring(0, pos);
      try {
        final Class<?> clazz = Class.forName(className);
View Full Code Here

Examples of com.orientechnologies.orient.core.record.impl.ODocument

    super(iDatabase, OGraphVertex.class.getSimpleName(), iPolymorphic);
  }

  @Override
  public OGraphVertex next(final String iFetchPlan) {
    final ODocument doc = underlying.next();

    OGraphVertex v = (OGraphVertex) database.getUserObjectByRecord(doc, null);

    if (v != null)
      return v;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.