Skip to content

Commit

Permalink
Integrated binary export into the distributed architecture. Issue #5455.
Browse files Browse the repository at this point in the history
plocal still need bug fixing.
  • Loading branch information
lvca committed Dec 10, 2015
1 parent 74a358a commit 5485f4f
Show file tree
Hide file tree
Showing 21 changed files with 909 additions and 242 deletions.
Expand Up @@ -43,17 +43,6 @@
import java.util.logging.FileHandler; import java.util.logging.FileHandler;
import java.util.logging.Level; import java.util.logging.Level;


import com.orientechnologies.common.io.OFileUtils;
import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.common.profiler.OProfiler;
import com.orientechnologies.common.util.OApi;
import com.orientechnologies.orient.core.OConstants;
import com.orientechnologies.orient.core.Orient;
import com.orientechnologies.orient.core.cache.ORecordCacheWeakRefs;
import com.orientechnologies.orient.core.metadata.OMetadataDefault;
import com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinary;
import com.orientechnologies.orient.core.storage.cache.local.O2QCache;

/** /**
* Keeps all configuration settings. At startup assigns the configuration values by reading system properties. * Keeps all configuration settings. At startup assigns the configuration values by reading system properties.
* *
Expand Down Expand Up @@ -97,22 +86,23 @@ public enum OGlobalConfiguration {
"Minimal amount of time (in seconds), since the last System.gc(), when called after tree optimization.", Long.class, 600), "Minimal amount of time (in seconds), since the last System.gc(), when called after tree optimization.", Long.class, 600),


// STORAGE // STORAGE
DISK_CACHE_PINNED_PAGES("storage.diskCache.pinnedPages", "Maximum amount of pinned pages which may be contained in cache," DISK_CACHE_PINNED_PAGES("storage.diskCache.pinnedPages",
+ " if this percent is reached next pages will be left in unpinned state. You can not set value more than 50", Integer.class, "Maximum amount of pinned pages which may be contained in cache,"
20, false), + " if this percent is reached next pages will be left in unpinned state. You can not set value more than 50",

Integer.class, 20, false),
DISK_CACHE_SIZE("storage.diskCache.bufferSize", "Size of disk buffer in megabytes, disk size may be changed at runtime, "
+ "but if does not enough to contain all pinned pages exception will be thrown.", Integer.class, 4 * 1024, DISK_CACHE_SIZE("storage.diskCache.bufferSize",
new OConfigurationChangeCallback() { "Size of disk buffer in megabytes, disk size may be changed at runtime, "
+ "but if does not enough to contain all pinned pages exception will be thrown.",
Integer.class, 4 * 1024, new OConfigurationChangeCallback() {
@Override @Override
public void change(Object currentValue, Object newValue) { public void change(Object currentValue, Object newValue) {
final OEngineLocalPaginated engineLocalPaginated = (OEngineLocalPaginated) Orient.instance() final OEngineLocalPaginated engineLocalPaginated = (OEngineLocalPaginated) Orient.instance()
.getEngine(OEngineLocalPaginated.NAME); .getEngine(OEngineLocalPaginated.NAME);


if (engineLocalPaginated == null) { if (engineLocalPaginated == null) {
OLogManager.instance().error(this, OLogManager.instance().error(this, "Can not change cache size in runtime because storage engine "
"Can not change cache size in runtime because storage engine " + OEngineLocalPaginated.NAME + OEngineLocalPaginated.NAME + " was not registered");
+ " was not registered");
} else { } else {
engineLocalPaginated.changeCacheSize(((Integer) (newValue)) * 1024L * 1024L); engineLocalPaginated.changeCacheSize(((Integer) (newValue)) * 1024L * 1024L);
} }
Expand Down Expand Up @@ -171,7 +161,7 @@ public void change(Object currentValue, Object newValue) {
"Indicates whether a full checkpoint should be performed, if storage was opened", Boolean.class, true), "Indicates whether a full checkpoint should be performed, if storage was opened", Boolean.class, true),


STORAGE_TRACK_CHANGED_RECORDS_IN_WAL("storage.trackChangedRecordsInWAL", STORAGE_TRACK_CHANGED_RECORDS_IN_WAL("storage.trackChangedRecordsInWAL",
"If this flag is set metadata " + "which contains rids of changed records is added at the end of each atomic operation", "If this flag is set metadata which contains rids of changed records is added at the end of each atomic operation",
Boolean.class, false), Boolean.class, false),


USE_WAL("storage.useWAL", "Whether WAL should be used in paginated storage.", Boolean.class, true), USE_WAL("storage.useWAL", "Whether WAL should be used in paginated storage.", Boolean.class, true),
Expand Down Expand Up @@ -731,10 +721,10 @@ public void change(final Object iCurrentValue, final Object iNewValue) {
private final Object defValue; private final Object defValue;
private final Class<?> type; private final Class<?> type;
private volatile Object value = null; private volatile Object value = null;
private final String description; private final String description;
private final OConfigurationChangeCallback changeCallback; private final OConfigurationChangeCallback changeCallback;
private final Boolean canChangeAtRuntime; private final Boolean canChangeAtRuntime;
private final boolean hidden; private final boolean hidden;


// AT STARTUP AUTO-CONFIG // AT STARTUP AUTO-CONFIG
static { static {
Expand Down
Expand Up @@ -19,14 +19,6 @@
*/ */
package com.orientechnologies.orient.core.record; package com.orientechnologies.orient.core.record;


import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
import java.util.WeakHashMap;

import com.orientechnologies.common.exception.OException; import com.orientechnologies.common.exception.OException;
import com.orientechnologies.common.io.OIOUtils; import com.orientechnologies.common.io.OIOUtils;
import com.orientechnologies.orient.core.db.ODatabase; import com.orientechnologies.orient.core.db.ODatabase;
Expand All @@ -45,6 +37,15 @@
import com.orientechnologies.orient.core.storage.OStorage; import com.orientechnologies.orient.core.storage.OStorage;
import com.orientechnologies.orient.core.storage.impl.local.paginated.OOfflineClusterException; import com.orientechnologies.orient.core.storage.impl.local.paginated.OOfflineClusterException;


import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
import java.util.WeakHashMap;

@SuppressWarnings({ "unchecked", "serial" }) @SuppressWarnings({ "unchecked", "serial" })
public abstract class ORecordAbstract implements ORecord { public abstract class ORecordAbstract implements ORecord {
protected ORecordId _recordId; protected ORecordId _recordId;
Expand Down Expand Up @@ -194,6 +195,14 @@ public String toJSON(final String iFormat) {
return ORecordSerializerJSON.INSTANCE.toString(this, new StringBuilder(1024), iFormat == null ? "" : iFormat).toString(); return ORecordSerializerJSON.INSTANCE.toString(this, new StringBuilder(1024), iFormat == null ? "" : iFormat).toString();
} }


public void toJSON(final String iFormat, final OutputStream stream) throws IOException {
stream.write(toJSON(iFormat).toString().getBytes());
}

public void toJSON(final OutputStream stream) throws IOException {
stream.write(toJSON().toString().getBytes());
}

@Override @Override
public String toString() { public String toString() {
return (_recordId.isValid() ? _recordId : "") + (_source != null ? Arrays.toString(_source) : "[]") + " v" + _recordVersion; return (_recordId.isValid() ? _recordId : "") + (_source != null ? Arrays.toString(_source) : "[]") + " v" + _recordVersion;
Expand Down
Expand Up @@ -33,7 +33,7 @@ public class ORecordInternal {
*/ */
public static ORecordAbstract fill(final ORecord record, final ORID iRid, final int iVersion, final byte[] iBuffer, public static ORecordAbstract fill(final ORecord record, final ORID iRid, final int iVersion, final byte[] iBuffer,
final boolean iDirty) { final boolean iDirty) {
ORecordAbstract rec = (ORecordAbstract) record; final ORecordAbstract rec = (ORecordAbstract) record;
rec.fill(iRid, iVersion, iBuffer, iDirty); rec.fill(iRid, iVersion, iBuffer, iDirty);
return rec; return rec;
} }
Expand All @@ -42,7 +42,7 @@ public static ORecordAbstract fill(final ORecord record, final ORID iRid, final
* Internal only. Changes the identity of the record. * Internal only. Changes the identity of the record.
*/ */
public static ORecordAbstract setIdentity(final ORecord record, final int iClusterId, final long iClusterPosition) { public static ORecordAbstract setIdentity(final ORecord record, final int iClusterId, final long iClusterPosition) {
ORecordAbstract rec = (ORecordAbstract) record; final ORecordAbstract rec = (ORecordAbstract) record;
rec.setIdentity(iClusterId, iClusterPosition); rec.setIdentity(iClusterId, iClusterPosition);
return rec; return rec;
} }
Expand All @@ -51,7 +51,7 @@ public static ORecordAbstract setIdentity(final ORecord record, final int iClust
* Internal only. Changes the identity of the record. * Internal only. Changes the identity of the record.
*/ */
public static ORecordAbstract setIdentity(final ORecord record, final ORecordId iIdentity) { public static ORecordAbstract setIdentity(final ORecord record, final ORecordId iIdentity) {
ORecordAbstract rec = (ORecordAbstract) record; final ORecordAbstract rec = (ORecordAbstract) record;
rec.setIdentity(iIdentity); rec.setIdentity(iIdentity);
return rec; return rec;
} }
Expand All @@ -60,82 +60,82 @@ public static ORecordAbstract setIdentity(final ORecord record, final ORecordId
* Internal only. Unsets the dirty status of the record. * Internal only. Unsets the dirty status of the record.
*/ */
public static void unsetDirty(final ORecord record) { public static void unsetDirty(final ORecord record) {
ORecordAbstract rec = (ORecordAbstract) record; final ORecordAbstract rec = (ORecordAbstract) record;
rec.unsetDirty(); rec.unsetDirty();
} }


/** /**
* Internal only. Sets the version. * Internal only. Sets the version.
*/ */
public static void setVersion(final ORecord record, final int iVersion) { public static void setVersion(final ORecord record, final int iVersion) {
ORecordAbstract rec = (ORecordAbstract) record; final ORecordAbstract rec = (ORecordAbstract) record;
rec.setVersion(iVersion); rec.setVersion(iVersion);
} }


/** /**
* Internal only. Return the record type. * Internal only. Return the record type.
*/ */
public static byte getRecordType(ORecord record) { public static byte getRecordType(final ORecord record) {
ORecordAbstract rec = (ORecordAbstract) record; final ORecordAbstract rec = (ORecordAbstract) record;
return rec.getRecordType(); return rec.getRecordType();
} }


public static boolean isContentChanged(ORecord record) { public static boolean isContentChanged(final ORecord record) {
ORecordAbstract rec = (ORecordAbstract) record; final ORecordAbstract rec = (ORecordAbstract) record;
return rec.isContentChanged(); return rec.isContentChanged();
} }


public static void setContentChanged(ORecord record, boolean changed) { public static void setContentChanged(final ORecord record, final boolean changed) {
ORecordAbstract rec = (ORecordAbstract) record; final ORecordAbstract rec = (ORecordAbstract) record;
rec.setContentChanged(changed); rec.setContentChanged(changed);
} }


public static void clearSource(ORecord record) { public static void clearSource(final ORecord record) {
ORecordAbstract rec = (ORecordAbstract) record; final ORecordAbstract rec = (ORecordAbstract) record;
rec.clearSource(); rec.clearSource();
} }


public static void addIdentityChangeListener(ORecord record, OIdentityChangeListener identityChangeListener) { public static void addIdentityChangeListener(final ORecord record, final OIdentityChangeListener identityChangeListener) {
((ORecordAbstract) record).addIdentityChangeListener(identityChangeListener); ((ORecordAbstract) record).addIdentityChangeListener(identityChangeListener);
} }


public static void removeIdentityChangeListener(ORecord record, OIdentityChangeListener identityChangeListener) { public static void removeIdentityChangeListener(final ORecord record, final OIdentityChangeListener identityChangeListener) {
((ORecordAbstract) record).removeIdentityChangeListener(identityChangeListener); ((ORecordAbstract) record).removeIdentityChangeListener(identityChangeListener);
} }


public static void onBeforeIdentityChanged(ORecord record) { public static void onBeforeIdentityChanged(final ORecord record) {
((ORecordAbstract) record).onBeforeIdentityChanged(record); ((ORecordAbstract) record).onBeforeIdentityChanged(record);
} }


public static void onAfterIdentityChanged(ORecord record) { public static void onAfterIdentityChanged(final ORecord record) {
((ORecordAbstract) record).onAfterIdentityChanged(record); ((ORecordAbstract) record).onAfterIdentityChanged(record);
} }


/** /**
* Internal only. Executes a flat copy of the record. * Internal only. Executes a flat copy of the record.
*/ */
public <RET extends ORecord> RET flatCopy(ORecord record) { public <RET extends ORecord> RET flatCopy(final ORecord record) {
ORecordAbstract rec = (ORecordAbstract) record; final ORecordAbstract rec = (ORecordAbstract) record;
return rec.flatCopy(); return rec.flatCopy();
} }


public static void setRecordSerializer(ORecord record, ORecordSerializer serializer) { public static void setRecordSerializer(final ORecord record, final ORecordSerializer serializer) {
((ORecordAbstract) record)._recordFormat = serializer; ((ORecordAbstract) record)._recordFormat = serializer;
} }


public static ODirtyManager getDirtyManager(ORecord record) { public static ODirtyManager getDirtyManager(final ORecord record) {
return ((ORecordAbstract) record).getDirtyManager(); return ((ORecordAbstract) record).getDirtyManager();
} }


public static void setDirtyManager(ORecord record, ODirtyManager dirtyManager) { public static void setDirtyManager(final ORecord record, final ODirtyManager dirtyManager) {
((ORecordAbstract) record).setDirtyManager(dirtyManager); ((ORecordAbstract) record).setDirtyManager(dirtyManager);
} }


public static void track(ORecord pointer, OIdentifiable pointed) { public static void track(final ORecord pointer, final OIdentifiable pointed) {
((ORecordAbstract) pointer).track(pointed); ((ORecordAbstract) pointer).track(pointed);
} }


public static void unTrack(ORecord pointer, OIdentifiable pointed) { public static void unTrack(final ORecord pointer, final OIdentifiable pointed) {
((ORecordAbstract) pointer).unTrack(pointed); ((ORecordAbstract) pointer).unTrack(pointed);
} }
} }

0 comments on commit 5485f4f

Please sign in to comment.