affdc7f2fa57ac7fb4175880f4a23f4724542921
[music.git] / src / main / java / org / onap / music / service / MusicCoreService.java
1 /*
2  * ============LICENSE_START==========================================
3  * org.onap.music
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
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  * ============LICENSE_END=============================================
20  * ====================================================================
21  */
22
23 package org.onap.music.service;
24
25 import java.util.List;
26 import java.util.Map;
27
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.MusicLockState;
33 import org.onap.music.main.ResultType;
34 import org.onap.music.main.ReturnType;
35 import org.onap.music.datastore.*;
36
37 import com.datastax.driver.core.ResultSet;
38
39 public interface MusicCoreService {
40
41     
42     // Core Music Database Methods
43     
44
45     public ReturnType eventualPut(PreparedQueryObject queryObject);
46     
47     public  ReturnType eventualPut_nb(PreparedQueryObject queryObject,String keyspace,String tablename,String primaryKey);
48
49     public ReturnType criticalPut(String keyspaceName, String tableName, String primaryKey,
50             PreparedQueryObject queryObject, String lockId, Condition conditionInfo);
51
52     public ResultType nonKeyRelatedPut(PreparedQueryObject queryObject, String consistency)
53             throws MusicServiceException;
54
55     public ResultSet get(PreparedQueryObject queryObject) throws MusicServiceException;
56
57     public ResultSet atomicGet(String keyspaceName, String tableName, String primaryKey,
58             PreparedQueryObject queryObject) throws MusicServiceException, MusicLockingException, MusicQueryException;
59
60     public ReturnType atomicPutWithDeleteLock(String keyspaceName, String tableName, String primaryKey,
61             PreparedQueryObject queryObject, Condition conditionInfo) throws MusicLockingException;
62     
63     public  ResultSet atomicGetWithDeleteLock(String keyspaceName, String tableName, String primaryKey,
64             PreparedQueryObject queryObject) throws MusicServiceException, MusicLockingException;
65
66     public ReturnType atomicPut(String keyspaceName, String tableName, String primaryKey,
67             PreparedQueryObject queryObject, Condition conditionInfo)
68             throws MusicLockingException, MusicQueryException, MusicServiceException;
69
70     public ResultSet criticalGet(String keyspaceName, String tableName, String primaryKey,
71             PreparedQueryObject queryObject, String lockId) throws MusicServiceException;
72
73     // Core Music Locking Service Methods
74
75     public String createLockReference(String fullyQualifiedKey); // lock name
76
77     public ReturnType acquireLockWithLease(String key, String lockReference, long leasePeriod)
78             throws MusicLockingException, MusicQueryException, MusicServiceException; // key,lock id,time
79
80     public ReturnType acquireLock(String key, String lockReference)
81             throws MusicLockingException, MusicQueryException, MusicServiceException; // key,lock id
82
83     public ResultType createTable(String keyspace, String table, PreparedQueryObject tableQueryObject,
84             String consistency) throws MusicServiceException;
85
86     public ResultSet quorumGet(PreparedQueryObject query);
87
88     public String whoseTurnIsIt(String fullyQualifiedKey);// lock name
89
90     public void destroyLockRef(String lockId);
91     
92     //public MusicLockState destroyLockRef(String fullyQualifiedKey, String lockReference); // lock name, lock id
93
94     //public MusicLockState voluntaryReleaseLock(String fullyQualifiedKey, String lockReference)
95     //        throws MusicLockingException;// lock name,lock id
96
97     public void deleteLock(String lockName) throws MusicLockingException;
98     
99     //public MusicLockState  forciblyReleaseLock(String fullyQualifiedKey, String lockReference) throws MusicLockingException, MusicServiceException, MusicQueryException;
100
101     public List<String> getLockQueue(String fullyQualifiedKey)
102             throws MusicServiceException, MusicQueryException, MusicLockingException;
103     
104      public long getLockQueueSize(String fullyQualifiedKey)
105                 throws MusicServiceException, MusicQueryException, MusicLockingException;
106
107     public Map<String, Object> validateLock(String lockName);
108
109     public MusicLockState releaseLock(String lockId, boolean voluntaryRelease);
110 }