1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.service;
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;
26 public interface XSupport {
28 * Writes illegal data into the current cluster cluster stream.
30 * @param r is resource used to identify cluster. If null then all clusters
31 * streams are corrupted.
33 void corruptCluster(Resource r)
34 throws DatabaseException;
36 * Creates new cluster proxy for given clusterId.
37 * Depending on the cluster id this proxy is valid or invalid.
39 * @param clusterId is used to identify cluster.
40 * @return index of cluster proxy in cluster table.
41 * @throws DatabaseException
43 int corruptClusterTable(long clusterId)
44 throws DatabaseException;
46 * Flush all modified data in the given cluster stream to server.
48 * @param r is resource used to identify cluster. If null then all clusters
49 * streams are flushed.
51 void flushCluster(Resource r)
52 throws ServiceException;
55 * Forcibly breaks underlying connection.
57 void breakConnection()
58 throws DatabaseException;
60 * Set cluster stream on or off.
62 * @param setOff true if cluster stream is turned off
63 * @throws DatabaseException
65 void setClusterStreamOff(boolean setOff)
66 throws DatabaseException;
69 * Clears the meta data cache.
71 * @return count of meta data entries in cache before clearing
72 * @throws DatabaseException
74 int clearMetadataCache()
75 throws DatabaseException;
77 * Sends commit message to server but does not end transaction.
78 * @param wgraph Write graph to ensure that this is called inside transaction.
81 <T> void commitAndContinue(WriteOnlyGraph wograph, WriteTraits wtraits);
84 * Get cluster's immutable property.
86 * @param resource used to get cluster.
87 * @return true if cluster is immutable.
88 * @throws DatabaseException
90 boolean getImmutable(Resource resource)
91 throws DatabaseException;
93 * Set cluster's immutable property.
95 * @param resource used to get cluster.
96 * @param immutable value to set.
97 * @throws DatabaseException
99 void setImmutable(Resource resource, boolean immutable)
100 throws DatabaseException;
103 * @param allowImmutableWrites <code>true</code> to allow writing to immutable cluster
104 * @param createAsImmutable <code>true</code> to make all created clusters immutable
106 void setServiceMode(boolean allowImmutableWrites, boolean createAsImmutable);
107 Pair<Boolean,Boolean> getServiceMode();
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.
114 * @param resource to convert.
115 * @return converted resource if it was acquired from delayed write request.
116 * Otherwise returns input resource.
118 Resource convertDelayedResourceToResource(Resource resource);
121 * Execute given command on server.
123 * @return result of the command
124 * @throws DatabaseException
126 String execute(String command)
127 throws DatabaseException;
129 * Tests cluster functionality.
130 * Database session is needed but no layer0.
131 * Enables us to test cluster implementation without layer0.
135 void testCluster(Session session)
136 throws DatabaseException;
139 * Writes garbage to server page table and exits server with -1 exit code.
141 * @throws DatabaseException
143 public void corruptPageTableAndDie()
144 throws DatabaseException;
147 * Returns clusters known to server.
148 * @throws DatabaseException
150 public ClusterUID[] listClusters()
151 throws DatabaseException;
154 * Deletes given cluster from server.
156 * @throws DatabaseException
158 public void deleteCluster(ClusterUID clusterUID)
159 throws DatabaseException;
160 public void purge() throws DatabaseException;
162 public boolean rolledback();