2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (c) 2017 AT&T Intellectual Property
6 * ===================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * ============LICENSE_END=============================================
20 * ====================================================================
23 package org.onap.music.service;
25 import java.util.List;
28 import javax.ws.rs.core.MultivaluedMap;
30 import org.onap.music.datastore.Condition;
31 import org.onap.music.datastore.PreparedQueryObject;
32 import org.onap.music.datastore.jsonobjects.JsonDelete;
33 import org.onap.music.datastore.jsonobjects.JsonIndex;
34 import org.onap.music.datastore.jsonobjects.JsonInsert;
35 import org.onap.music.datastore.jsonobjects.JsonKeySpace;
36 import org.onap.music.datastore.jsonobjects.JsonSelect;
37 import org.onap.music.datastore.jsonobjects.JsonTable;
38 import org.onap.music.datastore.jsonobjects.JsonUpdate;
39 import org.onap.music.exceptions.MusicLockingException;
40 import org.onap.music.exceptions.MusicQueryException;
41 import org.onap.music.exceptions.MusicServiceException;
42 import org.onap.music.lockingservice.cassandra.LockType;
43 import org.onap.music.lockingservice.cassandra.MusicLockState;
44 import org.onap.music.main.ResultType;
45 import org.onap.music.main.ReturnType;
47 import com.datastax.driver.core.ResultSet;
49 public interface MusicCoreService {
52 // Core Music Database Methods
55 public ReturnType eventualPut(PreparedQueryObject queryObject);
57 public ReturnType eventualPut_nb(PreparedQueryObject queryObject,String keyspace,String tablename,String primaryKey);
59 public ReturnType criticalPut(String keyspaceName, String tableName, String primaryKey,
60 PreparedQueryObject queryObject, String lockId, Condition conditionInfo);
62 public ResultType nonKeyRelatedPut(PreparedQueryObject queryObject, String consistency)
63 throws MusicServiceException,MusicQueryException;
65 public ResultSet get(PreparedQueryObject queryObject) throws MusicServiceException;
67 public ResultSet atomicGet(String keyspaceName, String tableName, String primaryKey,
68 PreparedQueryObject queryObject) throws MusicServiceException, MusicLockingException, MusicQueryException;
70 public ReturnType atomicPutWithDeleteLock(String keyspaceName, String tableName, String primaryKey,
71 PreparedQueryObject queryObject, Condition conditionInfo) throws MusicLockingException;
73 public ResultSet atomicGetWithDeleteLock(String keyspaceName, String tableName, String primaryKey,
74 PreparedQueryObject queryObject) throws MusicServiceException, MusicLockingException;
76 public ReturnType atomicPut(String keyspaceName, String tableName, String primaryKey,
77 PreparedQueryObject queryObject, Condition conditionInfo)
78 throws MusicLockingException, MusicQueryException, MusicServiceException;
80 public ResultSet criticalGet(String keyspaceName, String tableName, String primaryKey,
81 PreparedQueryObject queryObject, String lockId) throws MusicServiceException;
83 // Core Music Locking Service Methods
86 * Create a lock ref in the music lock store.
87 * Default is write as this is the safest semantically
89 * @param fullyQualifiedKey the key to create a lock on
90 * @see {@link #creatLockReference(String, LockType)}
92 public String createLockReference(String fullyQualifiedKey) throws MusicLockingException; // lock name
95 * Create a lock ref in the music lock store
96 * @param fullyQualifiedKey the key to create a lock on
97 * @param locktype the type of lock create, see {@link LockType}
99 public String createLockReference(String fullyQualifiedKey, LockType locktype) throws MusicLockingException;
101 public ReturnType acquireLockWithLease(String key, String lockReference, long leasePeriod)
102 throws MusicLockingException, MusicQueryException, MusicServiceException; // key,lock id,time
104 public ReturnType acquireLock(String key, String lockReference)
105 throws MusicLockingException, MusicQueryException, MusicServiceException; // key,lock id
107 public ResultType createTable(String keyspace, String table, PreparedQueryObject tableQueryObject,
108 String consistency) throws MusicServiceException;
110 public ResultSet quorumGet(PreparedQueryObject query);
113 * Gets top of queue for fullyQualifiedKey
114 * @param fullyQualifiedKey
117 public String whoseTurnIsIt(String fullyQualifiedKey);// lock name
120 * Gets the current lockholder(s) for lockName
124 public List<String> getCurrentLockHolders(String fullyQualifiedKey);
126 public void destroyLockRef(String lockId) throws MusicLockingException;
128 //public MusicLockState destroyLockRef(String fullyQualifiedKey, String lockReference); // lock name, lock id
130 //public MusicLockState voluntaryReleaseLock(String fullyQualifiedKey, String lockReference)
131 // throws MusicLockingException;// lock name,lock id
133 public void deleteLock(String lockName) throws MusicLockingException;
135 //public MusicLockState forciblyReleaseLock(String fullyQualifiedKey, String lockReference) throws MusicLockingException, MusicServiceException, MusicQueryException;
137 public List<String> getLockQueue(String fullyQualifiedKey)
138 throws MusicServiceException, MusicQueryException, MusicLockingException;
140 public long getLockQueueSize(String fullyQualifiedKey)
141 throws MusicServiceException, MusicQueryException, MusicLockingException;
143 public Map<String, Object> validateLock(String lockName);
145 public MusicLockState releaseLock(String lockId, boolean voluntaryRelease) throws MusicLockingException;
148 //Methods added for orm
151 public ResultType createTable(JsonTable jsonTableObject, String consistencyInfo) throws MusicServiceException,MusicQueryException;
153 public ResultType dropTable(JsonTable jsonTableObject, String consistencyInfo)
154 throws MusicServiceException,MusicQueryException;
156 public ResultType createKeyspace(JsonKeySpace jsonKeySpaceObject,String consistencyInfo) throws MusicServiceException,MusicQueryException;
158 public ResultType dropKeyspace(JsonKeySpace jsonKeySpaceObject, String consistencyInfo)
159 throws MusicServiceException,MusicQueryException;
161 public ResultType createIndex(JsonIndex jsonIndexObject, String consistencyInfo) throws MusicServiceException,MusicQueryException;
163 public ResultSet select(JsonSelect jsonSelect, MultivaluedMap<String, String> rowParams) throws MusicServiceException, MusicQueryException;
165 public ResultSet selectCritical(JsonInsert jsonInsertObj, MultivaluedMap<String, String> rowParams)
166 throws MusicLockingException, MusicQueryException, MusicServiceException;
168 public ReturnType insertIntoTable(JsonInsert jsonInsert) throws MusicLockingException, MusicQueryException, MusicServiceException;
170 public ReturnType updateTable(JsonUpdate jsonUpdateObj,MultivaluedMap<String, String> rowParams)
171 throws MusicLockingException, MusicQueryException, MusicServiceException;
173 public ReturnType deleteFromTable(JsonDelete jsonDeleteObj,MultivaluedMap<String, String> rowParams)
174 throws MusicLockingException, MusicQueryException, MusicServiceException;