1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.db.service;
\r
14 import org.simantics.db.Resource;
\r
15 import org.simantics.db.Session;
\r
16 import org.simantics.db.WriteOnlyGraph;
\r
17 import org.simantics.db.exception.DatabaseException;
\r
18 import org.simantics.db.exception.ServiceException;
\r
19 import org.simantics.db.request.WriteTraits;
\r
25 public interface XSupport {
\r
27 * Writes illegal data into the current cluster cluster stream.
\r
29 * @param r is resource used to identify cluster. If null then all clusters
\r
30 * streams are corrupted.
\r
32 void corruptCluster(Resource r)
\r
33 throws DatabaseException;
\r
35 * Creates new cluster proxy for given clusterId.
\r
36 * Depending on the cluster id this proxy is valid or invalid.
\r
38 * @param clusterId is used to identify cluster.
\r
39 * @return index of cluster proxy in cluster table.
\r
40 * @throws DatabaseException
\r
42 int corruptClusterTable(long clusterId)
\r
43 throws DatabaseException;
\r
45 * Flush all modified data in the given cluster stream to server.
\r
47 * @param r is resource used to identify cluster. If null then all clusters
\r
48 * streams are flushed.
\r
50 void flushCluster(Resource r)
\r
51 throws ServiceException;
\r
54 * Forcibly breaks underlying connection.
\r
56 void breakConnection()
\r
57 throws DatabaseException;
\r
59 * Set cluster stream on or off.
\r
61 * @param setOff true if cluster stream is turned off
\r
62 * @throws DatabaseException
\r
64 void setClusterStreamOff(boolean setOff)
\r
65 throws DatabaseException;
\r
68 * Clears the meta data cache.
\r
70 * @return count of meta data entries in cache before clearing
\r
71 * @throws DatabaseException
\r
73 int clearMetadataCache()
\r
74 throws DatabaseException;
\r
76 * Sends commit message to server but does not end transaction.
\r
77 * @param wgraph Write graph to ensure that this is called inside transaction.
\r
80 <T> void commitAndContinue(WriteOnlyGraph wograph, WriteTraits wtraits);
\r
83 * Get cluster's immutable property.
\r
85 * @param resource used to get cluster.
\r
86 * @return true if cluster is immutable.
\r
87 * @throws DatabaseException
\r
89 boolean getImmutable(Resource resource)
\r
90 throws DatabaseException;
\r
92 * Set cluster's immutable property.
\r
94 * @param resource used to get cluster.
\r
95 * @param immutable value to set.
\r
96 * @throws DatabaseException
\r
98 void setImmutable(Resource resource, boolean immutable)
\r
99 throws DatabaseException;
\r
102 * @param allowImmutableWrites <code>true</code> to allow writing to immutable cluster
\r
103 * @param createAsImmutable <code>true</code> to make all created clusters immutable
\r
105 void setServiceMode(boolean allowImmutableWrites, boolean createAsImmutable);
\r
108 * If resource is acquired from DelayedWriteGraph during delayed write request then
\r
109 * this method can be used to convert it to normal resource which can be use in
\r
110 * write and write only requests.
\r
112 * @param resource to convert.
\r
113 * @return converted resource if it was acquired from delayed write request.
\r
114 * Otherwise returns input resource.
\r
116 Resource convertDelayedResourceToResource(Resource resource);
\r
119 * Execute given command on server.
\r
121 * @return result of the command
\r
122 * @throws DatabaseException
\r
124 String execute(String command)
\r
125 throws DatabaseException;
\r
127 * Tests cluster functionality.
\r
128 * Database session is needed but no layer0.
\r
129 * Enables us to test cluster implementation without layer0.
\r
133 void testCluster(Session session)
\r
134 throws DatabaseException;
\r
137 * Writes garbage to server page table and exits server with -1 exit code.
\r
139 * @throws DatabaseException
\r
141 public void corruptPageTableAndDie()
\r
142 throws DatabaseException;
\r
145 * Returns clusters known to server.
\r
146 * @throws DatabaseException
\r
148 public ClusterUID[] listClusters()
\r
149 throws DatabaseException;
\r
152 * Deletes given cluster from server.
\r
153 * @param clusterUID
\r
154 * @throws DatabaseException
\r
156 public void deleteCluster(ClusterUID clusterUID)
\r
157 throws DatabaseException;
\r
158 public void purge() throws DatabaseException;
\r
160 public boolean rolledback();
\r