core/src/main/java/com/orientechnologies/orient/core/config/OStorageConfigurationImpl.java
public byte[] toStream(final int iNetworkVersion, Charset charset) throws OSerializationException {
    lock.acquireReadLock();
    try {
      final StringBuilder buffer = new StringBuilder(8192);

      write(buffer, CURRENT_VERSION);
      write(buffer, name);

      write(buffer, schemaRecordId);
      write(buffer, dictionaryRecordId);
      write(buffer, indexMgrRecordId);

      write(buffer, localeLanguage);
      write(buffer, localeCountry);
      write(buffer, dateFormat);
      write(buffer, dateTimeFormat);

      write(buffer, timeZone.getID());
      write(buffer, charset);
      if (iNetworkVersion > 24)
        write(buffer, conflictStrategy);

      phySegmentToStream(buffer, fileTemplate);

      write(buffer, clusters.size());
      for (OStorageClusterConfiguration c : clusters) {
        if (c == null) {
          write(buffer, -1);
          continue;
        }

        write(buffer, c.getId());
        write(buffer, c.getName());
        write(buffer, c.getDataSegmentId());

        if (c instanceof OStoragePaginatedClusterConfiguration) {
          write(buffer, "d");

          final OStoragePaginatedClusterConfiguration paginatedClusterConfiguration = (OStoragePaginatedClusterConfiguration) c;

          write(buffer, paginatedClusterConfiguration.useWal);
          write(buffer, paginatedClusterConfiguration.recordOverflowGrowFactor);
          write(buffer, paginatedClusterConfiguration.recordGrowFactor);
          write(buffer, paginatedClusterConfiguration.compression);

          if (iNetworkVersion >= 31)
            write(buffer, paginatedClusterConfiguration.encryption);
          if (iNetworkVersion > 24)
            write(buffer, paginatedClusterConfiguration.conflictStrategy);
          if (iNetworkVersion > 25)
            write(buffer, paginatedClusterConfiguration.getStatus().name());

          if (iNetworkVersion >= Integer.MAX_VALUE) {
            write(buffer, paginatedClusterConfiguration.getBinaryVersion());
          }
        }
      }
      if (iNetworkVersion <= 25) {
        // dataSegment array
        write(buffer, 0);
        // tx Segment File
        write(buffer, "");
        write(buffer, "");
        write(buffer, 0);
        // tx segment flags
        write(buffer, false);
        write(buffer, false);
      }
      synchronized (properties) {
        write(buffer, properties.size());
        for (OStorageEntryConfiguration e : properties)
          entryToStream(buffer, e);
      }

      write(buffer, binaryFormatVersion);
      write(buffer, clusterSelection);
      write(buffer, getMinimumClusters());

      if (iNetworkVersion > 24) {
        write(buffer, recordSerializer);
        write(buffer, recordSerializerVersion);

        // WRITE CONFIGURATION
        write(buffer, configuration.getContextSize());
        for (String k : configuration.getContextKeys()) {
          final OGlobalConfiguration cfg = OGlobalConfiguration.findByKey(k);
          write(buffer, k);
          if (cfg != null) {
            write(buffer, cfg.isHidden() ? null : configuration.getValueAsString(cfg));
          } else {
            write(buffer, null);
            OLogManager.instance().warn(this, "Storing configuration for property:'" + k + "' not existing in current version");
          }
        }
      }

      write(buffer, indexEngines.size());
      for (IndexEngineData engineData : indexEngines.values()) {
        write(buffer, engineData.getName());
        write(buffer, engineData.getAlgorithm());
        write(buffer, engineData.getIndexType() == null ? "" : engineData.getIndexType());

        write(buffer, engineData.getValueSerializerId());
        write(buffer, engineData.getKeySerializedId());

        write(buffer, engineData.isAutomatic());
        write(buffer, engineData.getDurableInNonTxMode());

        write(buffer, engineData.getVersion());
        write(buffer, engineData.isNullValuesSupport());
        write(buffer, engineData.getKeySize());
        write(buffer, engineData.getEncryption());
        write(buffer, engineData.getEncryptionOptions());

        if (engineData.getKeyTypes() != null) {
          write(buffer, engineData.getKeyTypes().length);
          for (OType type : engineData.getKeyTypes()) {
            write(buffer, type.name());
          }
        } else {
          write(buffer, 0);
        }

        if (engineData.getEngineProperties() == null) {
          write(buffer, 0);
        } else {
          write(buffer, engineData.getEngineProperties().size());
          for (Map.Entry<String, String> property : engineData.getEngineProperties().entrySet()) {
            write(buffer, property.getKey());
            write(buffer, property.getValue());
          }
        }

        write(buffer, engineData.getApiVersion());
        write(buffer, engineData.isMultivalue());
      }

      write(buffer, createdAtVersion);
      write(buffer, pageSize);
      write(buffer, freeListBoundary);
      write(buffer, maxKeySize);

      // PLAIN: ALLOCATE ENOUGH SPACE TO REUSE IT EVERY TIME
      buffer.append("|");

      return buffer.toString().getBytes(charset);
    } finally {
      lock.releaseReadLock();
    }
  }

  public void create() throws IOException {
    lock.acquireWriteLock();
    try {
      storage.createRecord(CONFIG_RID, new byte[] { 0, 0, 0, 0 }, 0, OBlob.RECORD_TYPE, null);
    } finally {
      lock.releaseWriteLock();
    }
  }
public byte[] toStream(final int iNetworkVersion, Charset charset) throws OSerializationException {
    lock.acquireReadLock();
    try {
      final StringBuilder buffer = new StringBuilder(8192);

      write(buffer, CURRENT_VERSION);
      write(buffer, name);

      write(buffer, schemaRecordId);
      write(buffer, dictionaryRecordId);
      write(buffer, indexMgrRecordId);

      write(buffer, localeLanguage);
      write(buffer, localeCountry);
      write(buffer, dateFormat);
      write(buffer, dateTimeFormat);

      write(buffer, timeZone.getID());
      write(buffer, charset);
      if (iNetworkVersion > 24)
        write(buffer, conflictStrategy);

      phySegmentToStream(buffer, fileTemplate);

      write(buffer, clusters.size());
      for (OStorageClusterConfiguration c : clusters) {
        if (c == null) {
          write(buffer, -1);
          continue;
        }

        write(buffer, c.getId());
        write(buffer, c.getName());
        write(buffer, c.getDataSegmentId());

        if (c instanceof OStoragePaginatedClusterConfiguration) {
          write(buffer, "d");

          final OStoragePaginatedClusterConfiguration paginatedClusterConfiguration = (OStoragePaginatedClusterConfiguration) c;

          write(buffer, paginatedClusterConfiguration.useWal);
          write(buffer, paginatedClusterConfiguration.recordOverflowGrowFactor);
          write(buffer, paginatedClusterConfiguration.recordGrowFactor);
          write(buffer, paginatedClusterConfiguration.compression);

          if (iNetworkVersion >= 31)
            write(buffer, paginatedClusterConfiguration.encryption);
          if (iNetworkVersion > 24)
            write(buffer, paginatedClusterConfiguration.conflictStrategy);
          if (iNetworkVersion > 25)
            write(buffer, paginatedClusterConfiguration.getStatus().name());

          if (iNetworkVersion >= Integer.MAX_VALUE) {
            write(buffer, paginatedClusterConfiguration.getBinaryVersion());
          }
        }
      }
      if (iNetworkVersion <= 25) {
        // dataSegment array
        write(buffer, 0);
        // tx Segment File
        write(buffer, "");
        write(buffer, "");
        write(buffer, 0);
        // tx segment flags
        write(buffer, false);
        write(buffer, false);
      }
      synchronized (properties) {
        write(buffer, properties.size());
        for (OStorageEntryConfiguration e : properties)
          entryToStream(buffer, e);
      }

      write(buffer, binaryFormatVersion);
      write(buffer, clusterSelection);
      write(buffer, getMinimumClusters());

      if (iNetworkVersion > 24) {
        write(buffer, recordSerializer);
        write(buffer, recordSerializerVersion);

        // WRITE CONFIGURATION
        write(buffer, configuration.getContextSize());
        for (String k : configuration.getContextKeys()) {
          final OGlobalConfiguration cfg = OGlobalConfiguration.findByKey(k);
          write(buffer, k);
          if (cfg != null) {
            write(buffer, cfg.isHidden() ? null : configuration.getValueAsString(cfg));
          } else {
            write(buffer, null);
            OLogManager.instance().warn(this, "Storing configuration for property:'" + k + "' not existing in current version");
          }
        }
      }

      write(buffer, indexEngines.size());
      for (IndexEngineData engineData : indexEngines.values()) {
        write(buffer, engineData.getName());
        write(buffer, engineData.getAlgorithm());
        write(buffer, engineData.getIndexType() == null ? "" : engineData.getIndexType());

        write(buffer, engineData.getValueSerializerId());
        write(buffer, engineData.getKeySerializedId());

        write(buffer, engineData.isAutomatic());
        write(buffer, engineData.getDurableInNonTxMode());

        write(buffer, engineData.getVersion());
        write(buffer, engineData.isNullValuesSupport());
        write(buffer, engineData.getKeySize());
        write(buffer, engineData.getEncryption());
        write(buffer, engineData.getEncryptionOptions());

        if (engineData.getKeyTypes() != null) {
          write(buffer, engineData.getKeyTypes().length);
          for (OType type : engineData.getKeyTypes()) {
            write(buffer, type.name());
          }
        } else {
          write(buffer, 0);
        }

        if (engineData.getEngineProperties() == null) {
          write(buffer, 0);
        } else {
          write(buffer, engineData.getEngineProperties().size());
          for (Map.Entry<String, String> property : engineData.getEngineProperties().entrySet()) {
            write(buffer, property.getKey());
            write(buffer, property.getValue());
          }
        }

        write(buffer, engineData.getApiVersion());
        write(buffer, engineData.isMultivalue());
      }

      write(buffer, createdAtVersion);
      write(buffer, pageSize);
      write(buffer, freeListBoundary);
      write(buffer, maxKeySize);

      // PLAIN: ALLOCATE ENOUGH SPACE TO REUSE IT EVERY TIME
      buffer.append("|");

      return buffer.toString().getBytes(charset);
    } finally {
      lock.releaseReadLock();
    }
  }

  public void create() throws IOException {
    lock.acquireWriteLock();
    try {
      storage.createRecord(CONFIG_RID, new byte[] { 0, 0, 0, 0 }, 0, OBlob.RECORD_TYPE, null);
    } finally {
      lock.releaseWriteLock();
    }
  }
public byte [ ] toStream ( final int iNetworkVersion , Charset charset ) throws OSerializationException { lock . acquireReadLock ( ) ; try { final StringBuilder buffer = new StringBuilder ( 8192 ) ; write ( buffer , CURRENT_VERSION ) ; write ( buffer , name ) ; write ( buffer , schemaRecordId ) ; write ( buffer , dictionaryRecordId ) ; write ( buffer , indexMgrRecordId ) ; write ( buffer , localeLanguage ) ; write ( buffer , localeCountry ) ; write ( buffer , dateFormat ) ; write ( buffer , dateTimeFormat ) ; write ( buffer , timeZone . getID ( ) ) ; write ( buffer , charset ) ; if ( iNetworkVersion > 24 ) write ( buffer , conflictStrategy ) ; phySegmentToStream ( buffer , fileTemplate ) ; write ( buffer , clusters . size ( ) ) ; for ( OStorageClusterConfiguration c : clusters ) { if ( c == null ) { write ( buffer , - 1 ) ; continue ; } write ( buffer , c . getId ( ) ) ; write ( buffer , c . getName ( ) ) ; write ( buffer , c . getDataSegmentId ( ) ) ; if ( c instanceof OStoragePaginatedClusterConfiguration ) { write ( buffer , "d" ) ; final OStoragePaginatedClusterConfiguration paginatedClusterConfiguration = ( OStoragePaginatedClusterConfiguration ) c ; write ( buffer , paginatedClusterConfiguration . useWal ) ; write ( buffer , paginatedClusterConfiguration . recordOverflowGrowFactor ) ; write ( buffer , paginatedClusterConfiguration . recordGrowFactor ) ; write ( buffer , paginatedClusterConfiguration . compression ) ; if ( iNetworkVersion >= 31 ) write ( buffer , paginatedClusterConfiguration . encryption ) ; if ( iNetworkVersion > 24 ) write ( buffer , paginatedClusterConfiguration . conflictStrategy ) ; if ( iNetworkVersion > 25 ) write ( buffer , paginatedClusterConfiguration . getStatus ( ) . name ( ) ) ; if ( iNetworkVersion >= Integer . MAX_VALUE ) { write ( buffer , paginatedClusterConfiguration . getBinaryVersion ( ) ) ; } } } if ( iNetworkVersion <= 25 ) { // dataSegment array write ( buffer , 0 ) ; // tx Segment File write ( buffer , "" ) ; write ( buffer , "" ) ; write ( buffer , 0 ) ; // tx segment flags write ( buffer , false ) ; write ( buffer , false ) ; } synchronized ( properties ) { write ( buffer , properties . size ( ) ) ; for ( OStorageEntryConfiguration e : properties ) entryToStream ( buffer , e ) ; } write ( buffer , binaryFormatVersion ) ; write ( buffer , clusterSelection ) ; write ( buffer , getMinimumClusters ( ) ) ; if ( iNetworkVersion > 24 ) { write ( buffer , recordSerializer ) ; write ( buffer , recordSerializerVersion ) ; // WRITE CONFIGURATION write ( buffer , configuration . getContextSize ( ) ) ; for ( String k : configuration . getContextKeys ( ) ) { final OGlobalConfiguration cfg = OGlobalConfiguration . findByKey ( k ) ; write ( buffer , k ) ; if ( cfg != null ) { write ( buffer , cfg . isHidden ( ) ? null : configuration . getValueAsString ( cfg ) ) ; } else { write ( buffer , null ) ; OLogManager . instance ( ) . warn ( this , "Storing configuration for property:'" + k + "' not existing in current version" ) ; } } } write ( buffer , indexEngines . size ( ) ) ; for ( IndexEngineData engineData : indexEngines . values ( ) ) { write ( buffer , engineData . getName ( ) ) ; write ( buffer , engineData . getAlgorithm ( ) ) ; write ( buffer , engineData . getIndexType ( ) == null ? "" : engineData . getIndexType ( ) ) ; write ( buffer , engineData . getValueSerializerId ( ) ) ; write ( buffer , engineData . getKeySerializedId ( ) ) ; write ( buffer , engineData . isAutomatic ( ) ) ; write ( buffer , engineData . getDurableInNonTxMode ( ) ) ; write ( buffer , engineData . getVersion ( ) ) ; write ( buffer , engineData . isNullValuesSupport ( ) ) ; write ( buffer , engineData . getKeySize ( ) ) ; write ( buffer , engineData . getEncryption ( ) ) ; write ( buffer , engineData . getEncryptionOptions ( ) ) ; if ( engineData . getKeyTypes ( ) != null ) { write ( buffer , engineData . getKeyTypes ( ) . length ) ; for ( OType type : engineData . getKeyTypes ( ) ) { write ( buffer , type . name ( ) ) ; } } else { write ( buffer , 0 ) ; } if ( engineData . getEngineProperties ( ) == null ) { write ( buffer , 0 ) ; } else { write ( buffer , engineData . getEngineProperties ( ) . size ( ) ) ; for ( Map . Entry < String , String > property : engineData . getEngineProperties ( ) . entrySet ( ) ) { write ( buffer , property . getKey ( ) ) ; write ( buffer , property . getValue ( ) ) ; } } write ( buffer , engineData . getApiVersion ( ) ) ; write ( buffer , engineData . isMultivalue ( ) ) ; } write ( buffer , createdAtVersion ) ; write ( buffer , pageSize ) ; write ( buffer , freeListBoundary ) ; write ( buffer , maxKeySize ) ; // PLAIN: ALLOCATE ENOUGH SPACE TO REUSE IT EVERY TIME buffer . append ( "|" ) ; return buffer . toString ( ) . getBytes ( charset ) ; } finally { lock . releaseReadLock ( ) ; } } public void create ( ) throws IOException { lock . acquireWriteLock ( ) ; try { storage . createRecord ( CONFIG_RID , new byte [ ] { 0 , 0 , 0 , 0 } , 0 , OBlob . RECORD_TYPE , null ) ; } finally { lock . releaseWriteLock ( ) ; } }
Added version used for managed Network Versioning.
Added version used for managed Network Versioning .