]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db/src/org/simantics/db/service/XSupport.java
cf9e96e7833421fb7617cc9ebeaef422a9dd3947
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / service / XSupport.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.service;
13
14 import org.simantics.db.Resource;
15 import org.simantics.db.Session;
16 import org.simantics.db.WriteOnlyGraph;
17 import org.simantics.db.exception.DatabaseException;
18 import org.simantics.db.exception.ServiceException;
19 import org.simantics.db.request.WriteTraits;
20 import org.simantics.utils.datastructures.Pair;
21
22 /**
23  * @author TUOKSK
24  *
25  */
26 public interface XSupport {
27     /**
28      * Writes illegal data into the current cluster cluster stream.
29      *
30      * @param r is resource used to identify cluster. If null then all clusters
31      *        streams are corrupted.
32      */
33     void corruptCluster(Resource r)
34     throws DatabaseException;
35     /**
36      * Creates new cluster proxy for given clusterId.
37      * Depending on the cluster id this proxy is valid or invalid.
38      *
39      * @param clusterId is used to identify cluster.
40      * @return index of cluster proxy in cluster table.
41      * @throws DatabaseException
42      */
43     int corruptClusterTable(long clusterId)
44     throws DatabaseException;
45     /**
46      * Flush all modified data in the given cluster stream to server.
47      *
48      * @param r is resource used to identify cluster. If null then all clusters
49      *        streams are flushed.
50      */
51     void flushCluster(Resource r)
52     throws ServiceException;
53
54     /**
55      * Forcibly breaks underlying connection.
56      */
57     void breakConnection()
58     throws DatabaseException;
59     /**
60      * Set cluster stream on or off.
61      *
62      * @param setOff true if cluster stream is turned off
63      * @throws DatabaseException
64      */
65     void setClusterStreamOff(boolean setOff)
66     throws DatabaseException;
67
68     /**
69      * Clears the meta data cache.
70      *
71      * @return count of meta data entries in cache before clearing
72      * @throws DatabaseException
73      */
74     int clearMetadataCache()
75     throws DatabaseException;
76     /**
77      * Sends commit message to server but does not end transaction.
78      * @param wgraph Write graph to ensure that this is called inside transaction.
79      *
80      */
81     <T> void commitAndContinue(WriteOnlyGraph wograph, WriteTraits wtraits);
82
83     /**
84      * Get cluster's immutable property.
85      *
86      * @param resource used to get cluster.
87      * @return true if cluster is immutable.
88      * @throws DatabaseException
89      */
90     boolean getImmutable(Resource resource)
91     throws DatabaseException;
92     /**
93      * Set cluster's immutable property.
94      *
95      * @param resource used to get cluster.
96      * @param immutable value to set.
97      * @throws DatabaseException
98      */
99     void setImmutable(Resource resource, boolean immutable)
100     throws DatabaseException;
101
102     /**
103      * @param allowImmutableWrites <code>true</code> to allow writing to immutable cluster 
104      * @param createAsImmutable <code>true</code> to make all created clusters immutable
105      */
106     void setServiceMode(boolean allowImmutableWrites, boolean createAsImmutable);
107     Pair<Boolean,Boolean> getServiceMode();
108
109     /**
110      * If resource is acquired from DelayedWriteGraph during delayed write request then
111      * this method can be used to convert it to normal resource which can be use in
112      * write and write only requests.
113      *
114      * @param resource to convert.
115      * @return converted resource if it was acquired from delayed write request.
116      * Otherwise returns input resource.
117      */
118     Resource convertDelayedResourceToResource(Resource resource);
119
120     /**
121      * Execute given command on server.
122      * @param command
123      * @return result of the command
124      * @throws DatabaseException
125      */
126     String execute(String command)
127     throws DatabaseException;
128     /**
129      * Tests cluster functionality.
130      * Database session is needed but no layer0.
131      * Enables us to test cluster implementation without layer0.
132      *
133      * @param session
134      */
135     void testCluster(Session session)
136     throws DatabaseException;
137
138     /**
139      * Writes garbage to server page table and exits server with -1 exit code.
140      *
141      * @throws DatabaseException
142      */
143     public void corruptPageTableAndDie()
144     throws DatabaseException;
145
146     /**
147      * Returns clusters known to server.
148      * @throws DatabaseException
149      */
150     public ClusterUID[] listClusters()
151     throws DatabaseException;
152
153     /**
154      * Deletes given cluster from server.
155      * @param clusterUID
156      * @throws DatabaseException
157      */
158     public void deleteCluster(ClusterUID clusterUID)
159     throws DatabaseException;
160     public void purge() throws DatabaseException;
161
162     public boolean rolledback();
163     
164     public boolean isClusterLoaded(ClusterUID clusterUID) throws DatabaseException;
165     
166 }