Skip to content

Commit

Permalink
merged develop branch
Browse files Browse the repository at this point in the history
  • Loading branch information
luigidellaquila committed Jul 21, 2015
1 parent a854f49 commit 67331ef
Show file tree
Hide file tree
Showing 352 changed files with 13,671 additions and 11,971 deletions.
41 changes: 32 additions & 9 deletions .../main/java/com/orientechnologies/orient/client/remote/OSBTreeCollectionManagerRemote.java 100644 → 100755
Expand Up @@ -29,6 +29,9 @@
import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.common.serialization.types.OBinarySerializer;
import com.orientechnologies.common.serialization.types.OIntegerSerializer;
import com.orientechnologies.orient.core.OOrientShutdownListener;
import com.orientechnologies.orient.core.OOrientStartupListener;
import com.orientechnologies.orient.core.Orient;
import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.db.record.ridbag.ORidBag;
Expand All @@ -43,26 +46,39 @@
/**
* @author Artem Orobets (enisher-at-gmail.com)
*/
public class OSBTreeCollectionManagerRemote extends OSBTreeCollectionManagerAbstract {
public class OSBTreeCollectionManagerRemote extends OSBTreeCollectionManagerAbstract implements OOrientStartupListener,
OOrientShutdownListener {

private final OCollectionNetworkSerializer networkSerializer;
private boolean remoteCreationAllowed = false;
private final OCollectionNetworkSerializer networkSerializer;
private boolean remoteCreationAllowed = false;

private final ThreadLocal<Map<UUID, WeakReference<ORidBag>>> pendingCollections = new ThreadLocal<Map<UUID, WeakReference<ORidBag>>>() {
@Override
protected Map<UUID, WeakReference<ORidBag>> initialValue() {
return new HashMap<UUID, WeakReference<ORidBag>>();
}
};
private volatile ThreadLocal<Map<UUID, WeakReference<ORidBag>>> pendingCollections = new PendingCollectionsThreadLocal();

public OSBTreeCollectionManagerRemote() {
super();
networkSerializer = new OCollectionNetworkSerializer();

Orient.instance().registerWeakOrientStartupListener(this);
Orient.instance().registerWeakOrientShutdownListener(this);
}

public OSBTreeCollectionManagerRemote(OCollectionNetworkSerializer networkSerializer) {
super();
this.networkSerializer = networkSerializer;

Orient.instance().registerWeakOrientStartupListener(this);
Orient.instance().registerWeakOrientShutdownListener(this);
}

@Override
public void onShutdown() {
pendingCollections = null;
}

@Override
public void onStartup() {
if (pendingCollections == null)
pendingCollections = new PendingCollectionsThreadLocal();
}

@Override
Expand Down Expand Up @@ -144,4 +160,11 @@ public Map<UUID, OBonsaiCollectionPointer> changedIds() {
public void clearChangedIds() {
throw new UnsupportedOperationException();
}

private static class PendingCollectionsThreadLocal extends ThreadLocal<Map<UUID, WeakReference<ORidBag>>> {
@Override
protected Map<UUID, WeakReference<ORidBag>> initialValue() {
return new HashMap<UUID, WeakReference<ORidBag>>();
}
}
}

0 comments on commit 67331ef

Please sign in to comment.