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 createLockReferenceAtomic(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 owner the owner of the lock, for deadlock prevention
99 public String createLockReference(String fullyQualifiedKey, String owner) throws MusicLockingException;
102 * Create a lock ref in the music lock store
103 * @param fullyQualifiedKey the key to create a lock on
104 * @param locktype the type of lock create, see {@link LockType}
106 public String createLockReferenceAtomic(String fullyQualifiedKey, LockType locktype) throws MusicLockingException;
109 * Create a lock ref in the music lock store
110 * @param fullyQualifiedKey the key to create a lock on
111 * @param locktype the type of lock create, see {@link LockType}
112 * @param owner the owner of the lock, for deadlock prevention
114 public String createLockReference(String fullyQualifiedKey, LockType locktype, String owner) throws MusicLockingException;
116 public ReturnType acquireLockWithLease(String key, String lockReference, long leasePeriod)
117 throws MusicLockingException, MusicQueryException, MusicServiceException; // key,lock id,time
119 public ReturnType acquireLock(String key, String lockReference)
120 throws MusicLockingException, MusicQueryException, MusicServiceException; // key,lock id
122 public ResultType createTable(String keyspace, String table, PreparedQueryObject tableQueryObject,
123 String consistency) throws MusicServiceException;
125 public ResultSet quorumGet(PreparedQueryObject query);
128 * Gets top of queue for fullyQualifiedKey
129 * @param fullyQualifiedKey
132 public String whoseTurnIsIt(String fullyQualifiedKey);// lock name
135 * Gets the current lockholder(s) for lockName
139 public List<String> getCurrentLockHolders(String fullyQualifiedKey);
141 public void destroyLockRef(String lockId) throws MusicLockingException;
143 public void deleteLock(String lockName) throws MusicLockingException;
145 public ReturnType promoteLock(String lockIdToPromote) throws MusicLockingException;
147 public List<String> getLockQueue(String fullyQualifiedKey)
148 throws MusicServiceException, MusicQueryException, MusicLockingException;
150 public long getLockQueueSize(String fullyQualifiedKey)
151 throws MusicServiceException, MusicQueryException, MusicLockingException;
153 public Map<String, Object> validateLock(String lockName);
155 public MusicLockState releaseLock(String lockId, boolean voluntaryRelease) throws MusicLockingException;
157 public List<String> releaseAllLocksForOwner(String ownerId, String keyspace, String table) throws MusicLockingException, MusicServiceException, MusicQueryException;
160 //Methods added for orm
163 public ResultType createTable(JsonTable jsonTableObject, String consistencyInfo) throws MusicServiceException,MusicQueryException;
165 public ResultType dropTable(JsonTable jsonTableObject, String consistencyInfo)
166 throws MusicServiceException,MusicQueryException;
168 public ResultType createKeyspace(JsonKeySpace jsonKeySpaceObject,String consistencyInfo) throws MusicServiceException,MusicQueryException;
170 public ResultType dropKeyspace(JsonKeySpace jsonKeySpaceObject, String consistencyInfo)
171 throws MusicServiceException,MusicQueryException;
173 public ResultType createIndex(JsonIndex jsonIndexObject, String consistencyInfo) throws MusicServiceException,MusicQueryException;
175 public ResultSet select(JsonSelect jsonSelect, MultivaluedMap<String, String> rowParams) throws MusicServiceException, MusicQueryException;
177 public ResultSet selectCritical(JsonInsert jsonInsertObj, MultivaluedMap<String, String> rowParams)
178 throws MusicLockingException, MusicQueryException, MusicServiceException;
180 public ReturnType insertIntoTable(JsonInsert jsonInsert) throws MusicLockingException, MusicQueryException, MusicServiceException;
182 public ReturnType updateTable(JsonUpdate jsonUpdateObj,MultivaluedMap<String, String> rowParams)
183 throws MusicLockingException, MusicQueryException, MusicServiceException;
185 public ReturnType deleteFromTable(JsonDelete jsonDeleteObj,MultivaluedMap<String, String> rowParams)
186 throws MusicLockingException, MusicQueryException, MusicServiceException;