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;
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}
105 * @param owner the owner of the lock, for deadlock prevention
107 public String createLockReference(String fullyQualifiedKey, LockType locktype, String owner) throws MusicLockingException;
109 public ReturnType acquireLockWithLease(String key, String lockReference, long leasePeriod)
110 throws MusicLockingException, MusicQueryException, MusicServiceException; // key,lock id,time
112 public ReturnType acquireLock(String key, String lockReference)
113 throws MusicLockingException, MusicQueryException, MusicServiceException; // key,lock id
115 public ResultType createTable(String keyspace, String table, PreparedQueryObject tableQueryObject,
116 String consistency) throws MusicServiceException;
118 public ResultSet quorumGet(PreparedQueryObject query);
121 * Gets top of queue for fullyQualifiedKey
122 * @param fullyQualifiedKey
125 public String whoseTurnIsIt(String fullyQualifiedKey);// lock name
128 * Gets the current lockholder(s) for lockName
132 public List<String> getCurrentLockHolders(String fullyQualifiedKey);
134 public void destroyLockRef(String lockId) throws MusicLockingException;
136 public void deleteLock(String lockName) throws MusicLockingException;
138 public ReturnType promoteLock(String lockIdToPromote) throws MusicLockingException;
140 public List<String> getLockQueue(String fullyQualifiedKey)
141 throws MusicServiceException, MusicQueryException, MusicLockingException;
143 public long getLockQueueSize(String fullyQualifiedKey)
144 throws MusicServiceException, MusicQueryException, MusicLockingException;
146 public Map<String, Object> validateLock(String lockName);
148 public MusicLockState releaseLock(String lockId, boolean voluntaryRelease) throws MusicLockingException;
150 public List<String> releaseAllLocksForOwner(String ownerId, String keyspace, String table) throws MusicLockingException, MusicServiceException, MusicQueryException;
153 //Methods added for orm
156 public ResultType createTable(JsonTable jsonTableObject, String consistencyInfo) throws MusicServiceException,MusicQueryException;
158 public ResultType dropTable(JsonTable jsonTableObject, String consistencyInfo)
159 throws MusicServiceException,MusicQueryException;
161 public ResultType createKeyspace(JsonKeySpace jsonKeySpaceObject,String consistencyInfo) throws MusicServiceException,MusicQueryException;
163 public ResultType dropKeyspace(JsonKeySpace jsonKeySpaceObject, String consistencyInfo)
164 throws MusicServiceException,MusicQueryException;
166 public ResultType createIndex(JsonIndex jsonIndexObject, String consistencyInfo) throws MusicServiceException,MusicQueryException;
168 public ResultSet select(JsonSelect jsonSelect, MultivaluedMap<String, String> rowParams) throws MusicServiceException, MusicQueryException;
170 public ResultSet selectCritical(JsonInsert jsonInsertObj, MultivaluedMap<String, String> rowParams)
171 throws MusicLockingException, MusicQueryException, MusicServiceException;
173 public ReturnType insertIntoTable(JsonInsert jsonInsert) throws MusicLockingException, MusicQueryException, MusicServiceException;
175 public ReturnType updateTable(JsonUpdate jsonUpdateObj,MultivaluedMap<String, String> rowParams)
176 throws MusicLockingException, MusicQueryException, MusicServiceException;
178 public ReturnType deleteFromTable(JsonDelete jsonDeleteObj,MultivaluedMap<String, String> rowParams)
179 throws MusicLockingException, MusicQueryException, MusicServiceException;