X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db%2Fsrc%2Forg%2Fsimantics%2Fdb%2FDatabase.java;fp=bundles%2Forg.simantics.db%2Fsrc%2Forg%2Fsimantics%2Fdb%2FDatabase.java;h=8d30e11bcc6e3ac0f912bd83557c54e3e848c4b2;hp=c80abd27d0e456e79aabe07a4881138cbb94804f;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.db/src/org/simantics/db/Database.java b/bundles/org.simantics.db/src/org/simantics/db/Database.java index c80abd27d..8d30e11bc 100644 --- a/bundles/org.simantics.db/src/org/simantics/db/Database.java +++ b/bundles/org.simantics.db/src/org/simantics/db/Database.java @@ -1,153 +1,153 @@ -package org.simantics.db; - -import java.io.File; -import java.nio.ByteBuffer; -import java.nio.file.Path; -import java.util.Properties; - -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.exception.SDBException; -import org.simantics.db.service.ClusterUID; - -public interface Database { - static public enum Status { - NoDatabase { @Override public String getString() { return "NoDatabase"; }}, - NotRunning { @Override public String getString() { return "NotRunning"; }}, - Standalone { @Override public String getString() { return "Standalone"; }}, - Local { @Override public String getString() { return "Local"; }}, - Remote { @Override public String getString() { return "Remote";}}; - public abstract String getString(); - @Override - public String toString() { - return message; - } - public String message = ""; - } - public DatabaseUserAgent getUserAgent(); - public void setUserAgent(DatabaseUserAgent dbUserAgent); - public Status getStatus(); - - public File getFolder(); - public boolean isFolderOk(); - public boolean isFolderOk(File aFolder); - public boolean isFolderEmpty(); - public boolean isFolderEmpty(File aFolder); - public void initFolder(Properties properties) throws SDBException; - public void deleteFiles() throws SDBException; - - public void start() throws SDBException; - public boolean isRunning() throws SDBException; - public boolean tryToStop() throws SDBException; - - public void connect() throws SDBException; - public boolean isConnected() throws SDBException; - public String execute(String command) throws SDBException; - public void disconnect() throws SDBException; - - public void clone(File to, int revision, boolean saveHistory) throws SDBException; - public Path createFromChangeSets(int revision) throws SDBException; - public void deleteGuard() throws SDBException; - public Path dumpChangeSets() throws SDBException; - public void purgeDatabase() throws SDBException; - public long serverGetTailChangeSetId() throws SDBException; - - public interface Session { - public Database getDatabase(); // Convenience method. - public void close() throws SDBException; - public void open() throws SDBException; - public boolean isClosed() throws SDBException; - public interface ChangeSetData { - public boolean isOk(); - } - public interface ChangeSetIds { - public long getFirstChangeSetId(); - public int getCount(); - } - public interface Cluster { - public int getInflateSize(); - public ByteBuffer getDeflated(); - } - public interface ClusterChanges { - public long getHeadChangeSetId(); - public int[] getResourceIndex(); - public int[] getPredicateIndex(); - public long[] getPredicateFirst(); - public long[] getPredicateSecond(); - public int[] getValueIndex(); - } - public interface ClusterIds { - public int getStatus(); - public long[] getFirst(); - public long[] getSecond(); - } - public interface Information { - public String getServerId(); - public String getProtocolId(); - public String getDatabaseId(); - public long getFirstChangeSetId(); - } - public interface Refresh { - public long getHeadChangeSetId(); - public long[] getFirst(); - public long[] getSecond(); - } - public interface ResourceSegment { - public byte[] getClusterId(); - public int getResourceIndex(); - public long getValueSize(); // Size of whole value. - public byte[] getSegment(); // Bytes of asked segment. - public long getOffset(); // Segment offset. - } - public interface Transaction { - public long getHeadChangeSetId(); - public long getTransactionId(); - } - interface OnChangeSetUpdate { - public void onChangeSetUpdate(ChangeSetUpdate changeSetUpdate) throws SDBException; - } - public void acceptCommit(long transactionId, long changeSetId, byte[] metadata) throws SDBException; - public long cancelCommit(long transactionId, long changeSetId, byte[] metadata, OnChangeSetUpdate onChangeSetUpdate) throws SDBException; - public Transaction askReadTransaction() throws SDBException; - public Transaction askWriteTransaction(long transactionId) throws SDBException; - public long endTransaction(long transactionId) throws SDBException; // Return head change set id. - public String execute(String command) throws SDBException; - public byte[] getChangeSetMetadata(long changeSetId) throws SDBException; - public ChangeSetData getChangeSetData(long minChangeSetId, long maxChangeSetId, OnChangeSetUpdate onChangeSetupate) throws SDBException; - public ChangeSetIds getChangeSetIds() throws SDBException; - public Cluster getCluster(byte[] clusterId) throws SDBException; - public ClusterChanges getClusterChanges(long changeSetId, byte[] clusterId) throws SDBException; - public ClusterIds getClusterIds() throws SDBException; - public Information getInformation() throws SDBException; - public Refresh getRefresh(long changeSetId) throws SDBException; - public ResourceSegment getResourceSegment(byte[] clusterUID, int resourceIndex, long offset, short size) throws SDBException; - public long reserveIds(int count) throws SDBException; - public void updateCluster(byte[] operations) throws SDBException; - public interface ChangeSetUpdate { - public long getChangeSetId(); - public int getChangeSetIndex(); - public int getNumberOfClusterChangeSets(); - public int getIndexOfClusterChangeSet(); - public byte[] getClusterId(); - public boolean getNewCluster(); - public byte[] getData(); - } - public boolean undo(long[] changeSetIds, OnChangeSetUpdate onChangeSetUpdate) throws SDBException; - - public T clone(ClusterUID clusterUID, ClusterCreator clusterCreator) throws DatabaseException; - public boolean refreshEnabled(); - public boolean rolledback(); - } - public Session newSession(ServiceLocator locator) throws SDBException; - interface Journal { - public class Line { - public boolean status; - public String request; - public String comment; - } - public boolean canRead(); - public int count(); - public int read(int index, Line line) throws SDBException; - } - public Journal getJournal() throws SDBException; - public String getCompression(); -} +package org.simantics.db; + +import java.io.File; +import java.nio.ByteBuffer; +import java.nio.file.Path; +import java.util.Properties; + +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.exception.SDBException; +import org.simantics.db.service.ClusterUID; + +public interface Database { + static public enum Status { + NoDatabase { @Override public String getString() { return "NoDatabase"; }}, + NotRunning { @Override public String getString() { return "NotRunning"; }}, + Standalone { @Override public String getString() { return "Standalone"; }}, + Local { @Override public String getString() { return "Local"; }}, + Remote { @Override public String getString() { return "Remote";}}; + public abstract String getString(); + @Override + public String toString() { + return message; + } + public String message = ""; + } + public DatabaseUserAgent getUserAgent(); + public void setUserAgent(DatabaseUserAgent dbUserAgent); + public Status getStatus(); + + public File getFolder(); + public boolean isFolderOk(); + public boolean isFolderOk(File aFolder); + public boolean isFolderEmpty(); + public boolean isFolderEmpty(File aFolder); + public void initFolder(Properties properties) throws SDBException; + public void deleteFiles() throws SDBException; + + public void start() throws SDBException; + public boolean isRunning() throws SDBException; + public boolean tryToStop() throws SDBException; + + public void connect() throws SDBException; + public boolean isConnected() throws SDBException; + public String execute(String command) throws SDBException; + public void disconnect() throws SDBException; + + public void clone(File to, int revision, boolean saveHistory) throws SDBException; + public Path createFromChangeSets(int revision) throws SDBException; + public void deleteGuard() throws SDBException; + public Path dumpChangeSets() throws SDBException; + public void purgeDatabase() throws SDBException; + public long serverGetTailChangeSetId() throws SDBException; + + public interface Session { + public Database getDatabase(); // Convenience method. + public void close() throws SDBException; + public void open() throws SDBException; + public boolean isClosed() throws SDBException; + public interface ChangeSetData { + public boolean isOk(); + } + public interface ChangeSetIds { + public long getFirstChangeSetId(); + public int getCount(); + } + public interface Cluster { + public int getInflateSize(); + public ByteBuffer getDeflated(); + } + public interface ClusterChanges { + public long getHeadChangeSetId(); + public int[] getResourceIndex(); + public int[] getPredicateIndex(); + public long[] getPredicateFirst(); + public long[] getPredicateSecond(); + public int[] getValueIndex(); + } + public interface ClusterIds { + public int getStatus(); + public long[] getFirst(); + public long[] getSecond(); + } + public interface Information { + public String getServerId(); + public String getProtocolId(); + public String getDatabaseId(); + public long getFirstChangeSetId(); + } + public interface Refresh { + public long getHeadChangeSetId(); + public long[] getFirst(); + public long[] getSecond(); + } + public interface ResourceSegment { + public byte[] getClusterId(); + public int getResourceIndex(); + public long getValueSize(); // Size of whole value. + public byte[] getSegment(); // Bytes of asked segment. + public long getOffset(); // Segment offset. + } + public interface Transaction { + public long getHeadChangeSetId(); + public long getTransactionId(); + } + interface OnChangeSetUpdate { + public void onChangeSetUpdate(ChangeSetUpdate changeSetUpdate) throws SDBException; + } + public void acceptCommit(long transactionId, long changeSetId, byte[] metadata) throws SDBException; + public long cancelCommit(long transactionId, long changeSetId, byte[] metadata, OnChangeSetUpdate onChangeSetUpdate) throws SDBException; + public Transaction askReadTransaction() throws SDBException; + public Transaction askWriteTransaction(long transactionId) throws SDBException; + public long endTransaction(long transactionId) throws SDBException; // Return head change set id. + public String execute(String command) throws SDBException; + public byte[] getChangeSetMetadata(long changeSetId) throws SDBException; + public ChangeSetData getChangeSetData(long minChangeSetId, long maxChangeSetId, OnChangeSetUpdate onChangeSetupate) throws SDBException; + public ChangeSetIds getChangeSetIds() throws SDBException; + public Cluster getCluster(byte[] clusterId) throws SDBException; + public ClusterChanges getClusterChanges(long changeSetId, byte[] clusterId) throws SDBException; + public ClusterIds getClusterIds() throws SDBException; + public Information getInformation() throws SDBException; + public Refresh getRefresh(long changeSetId) throws SDBException; + public ResourceSegment getResourceSegment(byte[] clusterUID, int resourceIndex, long offset, short size) throws SDBException; + public long reserveIds(int count) throws SDBException; + public void updateCluster(byte[] operations) throws SDBException; + public interface ChangeSetUpdate { + public long getChangeSetId(); + public int getChangeSetIndex(); + public int getNumberOfClusterChangeSets(); + public int getIndexOfClusterChangeSet(); + public byte[] getClusterId(); + public boolean getNewCluster(); + public byte[] getData(); + } + public boolean undo(long[] changeSetIds, OnChangeSetUpdate onChangeSetUpdate) throws SDBException; + + public T clone(ClusterUID clusterUID, ClusterCreator clusterCreator) throws DatabaseException; + public boolean refreshEnabled(); + public boolean rolledback(); + } + public Session newSession(ServiceLocator locator) throws SDBException; + interface Journal { + public class Line { + public boolean status; + public String request; + public String comment; + } + public boolean canRead(); + public int count(); + public int read(int index, Line line) throws SDBException; + } + public Journal getJournal() throws SDBException; + public String getCompression(); +}