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