1 package org.ozoneDB.core.storage; 8 9 import org.ozoneDB.core.Env; 10 import org.ozoneDB.core.Permissions; 11 import org.ozoneDB.core.ObjectID; 12 import org.ozoneDB.DxLib.DxMap; 13 14 17 public abstract class AbstractCluster implements Cluster { 18 19 22 public transient Env env; 23 24 public transient AbstractClusterStore clusterStore; 25 26 protected Permissions permissions; 27 28 protected ClusterID clusterID; 29 30 33 protected DxMap containers; 34 35 public DxMap containers() { 36 return containers; 37 } 38 39 public Env env() { 40 return env; 41 } 42 43 public void setEnv(Env _env) { 44 this.env = _env; 45 } 46 47 public void setClusterStore(AbstractClusterStore _clusterStore) { 48 this.clusterStore = _clusterStore; 49 } 50 51 public Permissions permissions() { 52 return permissions; 53 } 54 55 public ClusterID clusterID() { 56 return clusterID; 57 } 58 59 public StorageObjectContainer containerForID(ObjectID id) { 60 return (StorageObjectContainer) containers.elementForKey(id); 61 } 62 63 public void removeContainer(StorageObjectContainer container) { 64 if (containers.removeForKey(container.id()) == null) { 65 throw new IllegalStateException ("Unable to remove container from cluster."); 66 } 67 } 68 69 public void registerContainer(StorageObjectContainer container) { 70 synchronized (container) { 71 container.setCluster(this); 72 if (containers.addForKey(container, container.id()) == false) { 73 throw new IllegalStateException ("Unable to add id " + container.id() + " to cluster " + clusterID()); 74 } 75 } 76 } 77 } 78 | Popular Tags |