diff options
author | Tschaen, Brendan <ctschaen@att.com> | 2019-02-25 17:31:00 -0500 |
---|---|---|
committer | Tschaen, Brendan <ctschaen@att.com> | 2019-02-26 11:51:24 -0500 |
commit | b58e1d3db05aed02b62a557bf14db6ea7b8df5f5 (patch) | |
tree | 52efe61d7a948c98d088b6c09e3a31fdc41f801f /src/main/java/org/onap/music/main | |
parent | 7c2316f479f338c4b0fd9a150d8b858cea3b377c (diff) |
Remove zookeeper reference
Test cachingUtil, and other test coverage increase
Remove unused code
Rebased ontop of authentication changes
Change-Id: I795a9a90d0863b03cc2a4917d4ff13a0a6fca1cc
Issue-ID: MUSIC-341
Signed-off-by: Tschaen, Brendan <ctschaen@att.com>
Diffstat (limited to 'src/main/java/org/onap/music/main')
-rw-r--r-- | src/main/java/org/onap/music/main/CronJobManager.java | 103 | ||||
-rwxr-xr-x | src/main/java/org/onap/music/main/MusicUtil.java | 4 |
2 files changed, 0 insertions, 107 deletions
diff --git a/src/main/java/org/onap/music/main/CronJobManager.java b/src/main/java/org/onap/music/main/CronJobManager.java deleted file mode 100644 index 0d7d9239..00000000 --- a/src/main/java/org/onap/music/main/CronJobManager.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * ============LICENSE_START========================================== - * org.onap.music - * =================================================================== - * Copyright (c) 2017 AT&T Intellectual Property - * =================================================================== - * Modifications Copyright (c) 2019 Samsung - * =================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END============================================= - * ==================================================================== - */ - -package org.onap.music.main; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Iterator; -import org.onap.music.authentication.CachingUtil; -import org.onap.music.datastore.PreparedQueryObject; -import org.onap.music.eelf.logging.EELFLoggerDelegate; -import org.onap.music.eelf.logging.format.AppMessages; -import org.onap.music.eelf.logging.format.ErrorSeverity; -import org.onap.music.eelf.logging.format.ErrorTypes; -import org.onap.music.exceptions.MusicLockingException; -import org.onap.music.exceptions.MusicServiceException; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.Row; - -@Component -public class CronJobManager { - - private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CronJobManager.class); - - private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); - - - @Scheduled(cron = "0 0 0 * * ?") - public void scheduleTaskWithFixedRate() { - logger.info("Executing cronjob to cleanup locks..", dateTimeFormatter.format(LocalDateTime.now()) ); - deleteLocksFromDB(); - } - - public void deleteLocksFromDB() { - PreparedQueryObject pQuery = new PreparedQueryObject(); - String consistency = MusicUtil.EVENTUAL; - pQuery.appendQueryString("CREATE TABLE IF NOT EXISTS admin.locks ( lock_id text PRIMARY KEY, ctime text)"); - try { - ResultType result = MusicCore.nonKeyRelatedPut(pQuery, consistency); - if ( result.equals(ResultType.FAILURE)) { - logger.error(EELFLoggerDelegate.errorLogger,"Error creating Admin.locks table.",AppMessages.QUERYERROR,ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR); - } - } catch (MusicServiceException e1) { - logger.error(EELFLoggerDelegate.errorLogger,e1,AppMessages.QUERYERROR,ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR); - } - - pQuery = new PreparedQueryObject(); - pQuery.appendQueryString( - "select * from admin.locks"); - try { - ResultSet rs = MusicCore.get(pQuery); - Iterator<Row> it = rs.iterator(); - StringBuilder deleteKeys = new StringBuilder(); - Boolean expiredKeys = false; - while (it.hasNext()) { - Row row = it.next(); - String id = row.getString("lock_id"); - long ctime = Long.parseLong(row.getString("ctime")); - if(System.currentTimeMillis() >= ctime + 24 * 60 * 60 * 1000) { - expiredKeys = true; - String new_id = id.substring(1); - try { - MusicCore.deleteLock(new_id); - } catch (MusicLockingException e) { - logger.info(EELFLoggerDelegate.applicationLogger, - e.getMessage()); - } - deleteKeys.append("'").append(id).append("'").append(","); - } - } - if(expiredKeys) { - deleteKeys.deleteCharAt(deleteKeys.length()-1); - CachingUtil.deleteKeysFromDB(deleteKeys.toString()); - } - } catch (MusicServiceException e) { - logger.error(EELFLoggerDelegate.errorLogger,e,AppMessages.CACHEERROR,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR); - } - } -} diff --git a/src/main/java/org/onap/music/main/MusicUtil.java b/src/main/java/org/onap/music/main/MusicUtil.java index 06eeb805..aa82ea97 100755 --- a/src/main/java/org/onap/music/main/MusicUtil.java +++ b/src/main/java/org/onap/music/main/MusicUtil.java @@ -58,7 +58,6 @@ import org.onap.music.exceptions.MusicQueryException; import org.onap.music.exceptions.MusicServiceException; import org.onap.music.service.MusicCoreService; import org.onap.music.service.impl.MusicCassaCore; -import org.onap.music.service.impl.MusicZKCore; import com.datastax.driver.core.ConsistencyLevel; import com.datastax.driver.core.DataType; @@ -94,7 +93,6 @@ public class MusicUtil { public static final String USERID = "userId"; public static final String PASSWORD = "password"; public static final String CASSANDRA = "cassandra"; - public static final String ZOOKEEPER = "zookeeper"; public static final String AUTHORIZATION = "Authorization"; @@ -788,8 +786,6 @@ public class MusicUtil { public static MusicCoreService getMusicCoreService() { if(getLockUsing().equals(MusicUtil.CASSANDRA)) return MusicCassaCore.getInstance(); - else if (getLockUsing().equals(MusicUtil.ZOOKEEPER)) - return MusicZKCore.getInstance(); else return MusicCassaCore.getInstance(); } |