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 org.onap.music.datastore.PreparedQueryObject;
29 import org.onap.music.exceptions.MusicLockingException;
30 import org.onap.music.exceptions.MusicQueryException;
31 import org.onap.music.exceptions.MusicServiceException;
32 import org.onap.music.lockingservice.cassandra.LockType;
33 import org.onap.music.lockingservice.cassandra.MusicLockState;
34 import org.onap.music.main.ResultType;
35 import org.onap.music.main.ReturnType;
36 import org.onap.music.datastore.*;
38 import com.datastax.driver.core.ResultSet;
40 public interface MusicCoreService {
43 // Core Music Database Methods
46 public ReturnType eventualPut(PreparedQueryObject queryObject);
48 public ReturnType eventualPut_nb(PreparedQueryObject queryObject,String keyspace,String tablename,String primaryKey);
50 public ReturnType criticalPut(String keyspaceName, String tableName, String primaryKey,
51 PreparedQueryObject queryObject, String lockId, Condition conditionInfo);
53 public ResultType nonKeyRelatedPut(PreparedQueryObject queryObject, String consistency)
54 throws MusicServiceException,MusicQueryException;
56 public ResultSet get(PreparedQueryObject queryObject) throws MusicServiceException;
58 public ResultSet atomicGet(String keyspaceName, String tableName, String primaryKey,
59 PreparedQueryObject queryObject) throws MusicServiceException, MusicLockingException, MusicQueryException;
61 public ReturnType atomicPutWithDeleteLock(String keyspaceName, String tableName, String primaryKey,
62 PreparedQueryObject queryObject, Condition conditionInfo) throws MusicLockingException;
64 public ResultSet atomicGetWithDeleteLock(String keyspaceName, String tableName, String primaryKey,
65 PreparedQueryObject queryObject) throws MusicServiceException, MusicLockingException;
67 public ReturnType atomicPut(String keyspaceName, String tableName, String primaryKey,
68 PreparedQueryObject queryObject, Condition conditionInfo)
69 throws MusicLockingException, MusicQueryException, MusicServiceException;
71 public ResultSet criticalGet(String keyspaceName, String tableName, String primaryKey,
72 PreparedQueryObject queryObject, String lockId) throws MusicServiceException;
74 // Core Music Locking Service Methods
77 * Create a lock ref in the music lock store.
78 * Default is write as this is the safest semantically
80 * @param fullyQualifiedKey the key to create a lock on
81 * @see {@link #creatLockReference(String, LockType)}
83 public String createLockReference(String fullyQualifiedKey) throws MusicLockingException; // lock name
86 * Create a lock ref in the music lock store
87 * @param fullyQualifiedKey the key to create a lock on
88 * @param locktype the type of lock create, see {@link LockType}
90 public String createLockReference(String fullyQualifiedKey, LockType locktype) throws MusicLockingException;
92 public ReturnType acquireLockWithLease(String key, String lockReference, long leasePeriod)
93 throws MusicLockingException, MusicQueryException, MusicServiceException; // key,lock id,time
95 public ReturnType acquireLock(String key, String lockReference)
96 throws MusicLockingException, MusicQueryException, MusicServiceException; // key,lock id
98 public ResultType createTable(String keyspace, String table, PreparedQueryObject tableQueryObject,
99 String consistency) throws MusicServiceException;
101 public ResultSet quorumGet(PreparedQueryObject query);
104 * Gets top of queue for fullyQualifiedKey
105 * @param fullyQualifiedKey
108 public String whoseTurnIsIt(String fullyQualifiedKey);// lock name
111 * Gets the current lockholder(s) for lockName
115 public List<String> getCurrentLockHolders(String fullyQualifiedKey);
117 public void destroyLockRef(String lockId) throws MusicLockingException;
119 //public MusicLockState destroyLockRef(String fullyQualifiedKey, String lockReference); // lock name, lock id
121 //public MusicLockState voluntaryReleaseLock(String fullyQualifiedKey, String lockReference)
122 // throws MusicLockingException;// lock name,lock id
124 public void deleteLock(String lockName) throws MusicLockingException;
126 //public MusicLockState forciblyReleaseLock(String fullyQualifiedKey, String lockReference) throws MusicLockingException, MusicServiceException, MusicQueryException;
128 public List<String> getLockQueue(String fullyQualifiedKey)
129 throws MusicServiceException, MusicQueryException, MusicLockingException;
131 public long getLockQueueSize(String fullyQualifiedKey)
132 throws MusicServiceException, MusicQueryException, MusicLockingException;
134 public Map<String, Object> validateLock(String lockName);
136 public MusicLockState releaseLock(String lockId, boolean voluntaryRelease) throws MusicLockingException;