and util files.
Fixed Testing issuse
Update Gitignore to include vscode.
Issue-ID: MUSIC-419
Signed-off-by: Nelson, Thomas (tn1381) <tn1381@att.com>
Change-Id: I202613f905e2ef0cde338e7c98074faf68bc649a
Signed-off-by: Nelson, Thomas (tn1381) <tn1381@att.com>
docs/Makefile
docs/_build
docs/conf.py
+
+#VSCODE
+.VSCODE
+.attach_pid*
+
+
+#jmeter
+jmeter.log
import org.onap.music.authentication.MusicAuthorizationFilter;
import org.onap.music.eelf.logging.EELFLoggerDelegate;
import org.onap.music.eelf.logging.MusicLoggingServletFilter;
-import org.onap.music.main.CipherUtil;
import org.onap.music.main.MusicUtil;
import org.onap.music.main.PropertiesLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
-import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.DependsOn;
@EnableScheduling
public class MusicApplication extends SpringBootServletInitializer {
+ private final String KEYSPACE_PATTERN = "/v2/keyspaces/*";
+ private final String LOCKS_PATTERN = "/v2/locks/*";
+ private final String Q_PATTERN = "/v2/priorityq/*";
+
@Autowired
private PropertiesLoader propertyLoader;
private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicApplication.class);
+
public static void main(String[] args) {
new MusicApplication().configure(new SpringApplicationBuilder(MusicApplication.class)).run(args);
}
propertyLoader.loadProperties();
}
- @Autowired
- private ApplicationContext appContext;
@Bean
@DependsOn("loadProperties")
propertyLoader.loadProperties();
if (MusicUtil.getIsCadi()) {
PropAccess propAccess = propAccess();
- CadiAuthFilter cadiFilter = new CadiAuthFilter(propAccess);
-
- return cadiFilter;
+ return new CadiAuthFilter(propAccess);
} else {
return (ServletRequest request, ServletResponse response, FilterChain chain) -> {
// do nothing for now.
FilterRegistrationBean<Filter> frb = new FilterRegistrationBean<>();
frb.setFilter(new MusicLoggingServletFilter());
frb.addUrlPatterns(
- "/v2/keyspaces/*",
- "/v2/locks/*",
- "/v2/priorityq/*"
+ KEYSPACE_PATTERN,
+ LOCKS_PATTERN,
+ Q_PATTERN
);
frb.setName("logFilter");
frb.setOrder(1);
return frb;
}
-
@Bean
@DependsOn("loadProperties")
logger.info("cadiFilterRegistration called for cadi filter..");
FilterRegistrationBean<Filter> frb = new FilterRegistrationBean<>();
frb.setFilter(cadiFilter());
-
- // The Following Patterns are used to control what APIs will be secure
- // TODO: Make this a configurable item. Build this from an array?
if (MusicUtil.getIsCadi()) {
frb.addUrlPatterns(
- "/v2/keyspaces/*",
- "/v2/locks/*",
- "/v2/priorityq/*"
+ KEYSPACE_PATTERN,
+ LOCKS_PATTERN,
+ Q_PATTERN
);
} else {
frb.addUrlPatterns("/v0/test");
if (MusicUtil.getIsCadi()) {
frb.addUrlPatterns(
- "/v2/keyspaces/*",
- "/v2/locks/*",
- "/v2/priorityq/*"
- );
+ KEYSPACE_PATTERN,
+ LOCKS_PATTERN,
+ Q_PATTERN
+ );
} else {
frb.addUrlPatterns("/v0/test");
}
public Filter cadiMusicAuthFilter() throws ServletException {
propertyLoader.loadProperties();
if (MusicUtil.getIsCadi()) {
- MusicAuthorizationFilter authFilter = new MusicAuthorizationFilter();
- return authFilter;
+ return new MusicAuthorizationFilter();
} else {
return (ServletRequest request, ServletResponse response, FilterChain chain) -> {
// do nothing for now.
import org.onap.music.lockingservice.cassandra.LockType;
import org.onap.music.lockingservice.cassandra.MusicLockState;
import org.onap.music.service.MusicCoreService;
-import org.onap.music.service.impl.MusicCassaCore;
import com.datastax.driver.core.ResultSet;
public class MusicCore {
private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicCore.class);
- private static boolean unitTestRun = true;
-
private static MusicCoreService musicCore = MusicUtil.getMusicCoreService();
- public static CassaLockStore mLockHandle;
+ private static CassaLockStore mLockHandle;
+
+ public static CassaLockStore getmLockHandle() {
+ return mLockHandle;
+ }
+ public static void setmLockHandle(CassaLockStore mLockHandleIn) {
+ mLockHandle = mLockHandleIn;
+ }
/**
* Acquire lock
return musicCore.releaseLock(lockId, voluntaryRelease);
}
+
+
}
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
-import java.util.concurrent.TimeUnit;
import org.onap.music.datastore.MusicDataStore;
import org.onap.music.datastore.MusicDataStoreHandle;
import org.onap.music.main.ReturnType;
import org.onap.music.service.MusicCoreService;
-import com.att.eelf.configuration.EELFLogger;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
public class MusicCassaCore implements MusicCoreService {
- public static CassaLockStore mLockHandle = null;;
+ private static CassaLockStore mLockHandle = null;
private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicCassaCore.class);
- private static boolean unitTestRun=true;
private static MusicCassaCore musicCassaCoreInstance = null;
private MusicCassaCore() {
+ // not going to happen
+ }
+
+ public static CassaLockStore getmLockHandle() {
+ return mLockHandle;
+ }
+ public static void setmLockHandle(CassaLockStore mLockHandle) {
+ MusicCassaCore.mLockHandle = mLockHandle;
}
+
public static MusicCassaCore getInstance() {
if(musicCassaCoreInstance == null) {
return musicCassaCoreInstance;
}
+
+
+
public static CassaLockStore getLockingServiceHandle() throws MusicLockingException {
logger.info(EELFLoggerDelegate.applicationLogger,"Acquiring lock store handle");
long start = System.currentTimeMillis();
}
public String createLockReference(String fullyQualifiedKey) throws MusicLockingException {
- return createLockReference(fullyQualifiedKey, LockType.WRITE);
+ return createLockReference(fullyQualifiedKey, LockType.WRITE);
}
public String createLockReference(String fullyQualifiedKey, LockType locktype) throws MusicLockingException {
public ReturnType acquireLockWithLease(String fullyQualifiedKey, String lockReference, long leasePeriod)
throws MusicLockingException, MusicQueryException, MusicServiceException {
- evictExpiredLockHolder(fullyQualifiedKey,leasePeriod);
- return acquireLock(fullyQualifiedKey, lockReference);
+ evictExpiredLockHolder(fullyQualifiedKey,leasePeriod);
+ return acquireLock(fullyQualifiedKey, lockReference);
}
private void evictExpiredLockHolder(String fullyQualifiedKey, long leasePeriod)
if (!lockInfo.getIsLockOwner()) {
return new ReturnType(ResultType.FAILURE, lockId + " is not a lock holder");//not top of the lock store q
}
-
+
//check to see if the value of the key has to be synced in case there was a forceful release
String syncTable = keyspace+".unsyncedKeys_"+table;
String query = "select * from "+syncTable+" where key='"+localFullyQualifiedKey+"';";
return null;
}
+
}
try {
ReflectionTestUtils.setField(MusicDataStoreHandle.class, "mDstoreHandle",
CassandraCQL.connectToEmbeddedCassandra());
- MusicCore.mLockHandle = new CassaLockStore(MusicDataStoreHandle.getDSHandle());
+ MusicCore.setmLockHandle(new CassaLockStore(MusicDataStoreHandle.getDSHandle()));
// System.out.println("before class keysp");
//resp=data.createKeySpace(majorV,minorV,patchV,aid,appName,userId,password,kspObject,keyspaceName);
public static void beforeClass() throws Exception {
ReflectionTestUtils.setField(MusicDataStoreHandle.class, "mDstoreHandle",
CassandraCQL.connectToEmbeddedCassandra());
- MusicCore.mLockHandle = new CassaLockStore(MusicDataStoreHandle.getDSHandle());
+ MusicCore.setmLockHandle(new CassaLockStore(MusicDataStoreHandle.getDSHandle()));
createAdminTable();
}