]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db/src/org/simantics/db/service/XSupport.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / service / XSupport.java
diff --git a/bundles/org.simantics.db/src/org/simantics/db/service/XSupport.java b/bundles/org.simantics.db/src/org/simantics/db/service/XSupport.java
new file mode 100644 (file)
index 0000000..d365d00
--- /dev/null
@@ -0,0 +1,160 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.db.service;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.WriteOnlyGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.db.request.WriteTraits;\r
+\r
+/**\r
+ * @author TUOKSK\r
+ *\r
+ */\r
+public interface XSupport {\r
+    /**\r
+     * Writes illegal data into the current cluster cluster stream.\r
+     *\r
+     * @param r is resource used to identify cluster. If null then all clusters\r
+     *        streams are corrupted.\r
+     */\r
+    void corruptCluster(Resource r)\r
+    throws DatabaseException;\r
+    /**\r
+     * Creates new cluster proxy for given clusterId.\r
+     * Depending on the cluster id this proxy is valid or invalid.\r
+     *\r
+     * @param clusterId is used to identify cluster.\r
+     * @return index of cluster proxy in cluster table.\r
+     * @throws DatabaseException\r
+     */\r
+    int corruptClusterTable(long clusterId)\r
+    throws DatabaseException;\r
+    /**\r
+     * Flush all modified data in the given cluster stream to server.\r
+     *\r
+     * @param r is resource used to identify cluster. If null then all clusters\r
+     *        streams are flushed.\r
+     */\r
+    void flushCluster(Resource r)\r
+    throws ServiceException;\r
+\r
+    /**\r
+     * Forcibly breaks underlying connection.\r
+     */\r
+    void breakConnection()\r
+    throws DatabaseException;\r
+    /**\r
+     * Set cluster stream on or off.\r
+     *\r
+     * @param setOff true if cluster stream is turned off\r
+     * @throws DatabaseException\r
+     */\r
+    void setClusterStreamOff(boolean setOff)\r
+    throws DatabaseException;\r
+\r
+    /**\r
+     * Clears the meta data cache.\r
+     *\r
+     * @return count of meta data entries in cache before clearing\r
+     * @throws DatabaseException\r
+     */\r
+    int clearMetadataCache()\r
+    throws DatabaseException;\r
+    /**\r
+     * Sends commit message to server but does not end transaction.\r
+     * @param wgraph Write graph to ensure that this is called inside transaction.\r
+     *\r
+     */\r
+    <T> void commitAndContinue(WriteOnlyGraph wograph, WriteTraits wtraits);\r
+\r
+    /**\r
+     * Get cluster's immutable property.\r
+     *\r
+     * @param resource used to get cluster.\r
+     * @return true if cluster is immutable.\r
+     * @throws DatabaseException\r
+     */\r
+    boolean getImmutable(Resource resource)\r
+    throws DatabaseException;\r
+    /**\r
+     * Set cluster's immutable property.\r
+     *\r
+     * @param resource used to get cluster.\r
+     * @param immutable value to set.\r
+     * @throws DatabaseException\r
+     */\r
+    void setImmutable(Resource resource, boolean immutable)\r
+    throws DatabaseException;\r
+\r
+    /**\r
+     * @param allowImmutableWrites <code>true</code> to allow writing to immutable cluster \r
+     * @param createAsImmutable <code>true</code> to make all created clusters immutable\r
+     */\r
+    void setServiceMode(boolean allowImmutableWrites, boolean createAsImmutable);\r
+\r
+    /**\r
+     * If resource is acquired from DelayedWriteGraph during delayed write request then\r
+     * this method can be used to convert it to normal resource which can be use in\r
+     * write and write only requests.\r
+     *\r
+     * @param resource to convert.\r
+     * @return converted resource if it was acquired from delayed write request.\r
+     * Otherwise returns input resource.\r
+     */\r
+    Resource convertDelayedResourceToResource(Resource resource);\r
+\r
+    /**\r
+     * Execute given command on server.\r
+     * @param command\r
+     * @return result of the command\r
+     * @throws DatabaseException\r
+     */\r
+    String execute(String command)\r
+    throws DatabaseException;\r
+    /**\r
+     * Tests cluster functionality.\r
+     * Database session is needed but no layer0.\r
+     * Enables us to test cluster implementation without layer0.\r
+     *\r
+     * @param session\r
+     */\r
+    void testCluster(Session session)\r
+    throws DatabaseException;\r
+\r
+    /**\r
+     * Writes garbage to server page table and exits server with -1 exit code.\r
+     *\r
+     * @throws DatabaseException\r
+     */\r
+    public void corruptPageTableAndDie()\r
+    throws DatabaseException;\r
+\r
+    /**\r
+     * Returns clusters known to server.\r
+     * @throws DatabaseException\r
+     */\r
+    public ClusterUID[] listClusters()\r
+    throws DatabaseException;\r
+\r
+    /**\r
+     * Deletes given cluster from server.\r
+     * @param clusterUID\r
+     * @throws DatabaseException\r
+     */\r
+    public void deleteCluster(ClusterUID clusterUID)\r
+    throws DatabaseException;\r
+    public void purge() throws DatabaseException;\r
+\r
+}\r