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;
25 public interface XSupport {
27 * Writes illegal data into the current cluster cluster stream.
29 * @param r is resource used to identify cluster. If null then all clusters
30 * streams are corrupted.
32 void corruptCluster(Resource r)
33 throws DatabaseException;
35 * Creates new cluster proxy for given clusterId.
36 * Depending on the cluster id this proxy is valid or invalid.
38 * @param clusterId is used to identify cluster.
39 * @return index of cluster proxy in cluster table.
40 * @throws DatabaseException
42 int corruptClusterTable(long clusterId)
43 throws DatabaseException;
45 * Flush all modified data in the given cluster stream to server.
47 * @param r is resource used to identify cluster. If null then all clusters
48 * streams are flushed.
50 void flushCluster(Resource r)
51 throws ServiceException;
54 * Forcibly breaks underlying connection.
56 void breakConnection()
57 throws DatabaseException;
59 * Set cluster stream on or off.
61 * @param setOff true if cluster stream is turned off
62 * @throws DatabaseException
64 void setClusterStreamOff(boolean setOff)
65 throws DatabaseException;
68 * Clears the meta data cache.
70 * @return count of meta data entries in cache before clearing
71 * @throws DatabaseException
73 int clearMetadataCache()
74 throws DatabaseException;
76 * Sends commit message to server but does not end transaction.
77 * @param wgraph Write graph to ensure that this is called inside transaction.
80 <T> void commitAndContinue(WriteOnlyGraph wograph, WriteTraits wtraits);
83 * Get cluster's immutable property.
85 * @param resource used to get cluster.
86 * @return true if cluster is immutable.
87 * @throws DatabaseException
89 boolean getImmutable(Resource resource)
90 throws DatabaseException;
92 * Set cluster's immutable property.
94 * @param resource used to get cluster.
95 * @param immutable value to set.
96 * @throws DatabaseException
98 void setImmutable(Resource resource, boolean immutable)
99 throws DatabaseException;
102 * @param allowImmutableWrites <code>true</code> to allow writing to immutable cluster
103 * @param createAsImmutable <code>true</code> to make all created clusters immutable
105 void setServiceMode(boolean allowImmutableWrites, boolean createAsImmutable);
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.
112 * @param resource to convert.
113 * @return converted resource if it was acquired from delayed write request.
114 * Otherwise returns input resource.
116 Resource convertDelayedResourceToResource(Resource resource);
119 * Execute given command on server.
121 * @return result of the command
122 * @throws DatabaseException
124 String execute(String command)
125 throws DatabaseException;
127 * Tests cluster functionality.
128 * Database session is needed but no layer0.
129 * Enables us to test cluster implementation without layer0.
133 void testCluster(Session session)
134 throws DatabaseException;
137 * Writes garbage to server page table and exits server with -1 exit code.
139 * @throws DatabaseException
141 public void corruptPageTableAndDie()
142 throws DatabaseException;
145 * Returns clusters known to server.
146 * @throws DatabaseException
148 public ClusterUID[] listClusters()
149 throws DatabaseException;
152 * Deletes given cluster from server.
154 * @throws DatabaseException
156 public void deleteCluster(ClusterUID clusterUID)
157 throws DatabaseException;
158 public void purge() throws DatabaseException;
160 public boolean rolledback();