/*
* ============LICENSE_START========================================== org.onap.music
* =================================================================== Copyright (c) 2017 AT&T
- * Intellectual Property ===================================================================
+ * Intellectual Property
+ * Modifications Copyright (C) 2018 IBM.
+ * ===================================================================
* 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
*
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriInfo;
-import org.apache.log4j.Logger;
import org.onap.music.datastore.jsonobjects.JsonInsert;
-import org.onap.music.datastore.jsonobjects.JsonOnboard;
-import org.onap.music.datastore.jsonobjects.JsonUpdate;
-import org.onap.music.main.CachingUtil;
+import org.onap.music.eelf.logging.EELFLoggerDelegate;
import org.onap.music.main.MusicCore;
import org.onap.music.main.MusicUtil;
import org.onap.music.main.ResultType;
import org.onap.music.main.ReturnType;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import org.onap.music.datastore.PreparedQueryObject;
import com.datastax.driver.core.DataType;
-import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.TableMetadata;
import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
/*
* These are functions created purely for benchmarking purposes. Commented out Swagger - This should
@Path("/v{version: [0-9]+}/benchmarks/")
@Api(value = "Benchmark API", hidden = true)
public class RestMusicBmAPI {
- private static EELFLogger logger = EELFManager.getInstance().getLogger(RestMusicBmAPI.class);
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicBmAPI.class);
+ public static final String UPDATE_CONST=" update-";
// pure zk calls...
/**
@Consumes(MediaType.APPLICATION_JSON)
public void pureZkUpdate(JsonInsert insObj, @PathParam("name") String nodeName)
throws Exception {
- logger.info("--------------Zk normal update-------------------------");
+ logger.info(EELFLoggerDelegate.applicationLogger,"--------------Zk normal update-------------------------");
long start = System.currentTimeMillis();
MusicCore.pureZkWrite(nodeName, insObj.serialize());
long end = System.currentTimeMillis();
- logger.info("Total time taken for Zk normal update:" + (end - start) + " ms");
+ logger.info(EELFLoggerDelegate.applicationLogger,"Total time taken for Zk normal update:" + (end - start) + " ms");
}
/**
String operationId = UUID.randomUUID().toString();// just for debugging purposes.
String consistency = updateObj.getConsistencyInfo().get("type");
- logger.info("--------------Zookeeper " + consistency + " update-" + operationId
+ logger.info(EELFLoggerDelegate.applicationLogger,"--------------Zookeeper " + consistency + UPDATE_CONST + operationId
+ "-------------------------");
byte[] data = updateObj.serialize();
long leasePeriod = MusicUtil.getDefaultLockLeasePeriod();
ReturnType lockAcqResult = MusicCore.acquireLockWithLease(lockname, lockId, leasePeriod);
long lockAcqTime = System.currentTimeMillis();
- long zkPutTime = 0, lockReleaseTime = 0;
+ long zkPutTime = 0;
+ long lockReleaseTime = 0;
if (lockAcqResult.getResult().equals(ResultType.SUCCESS)) {
- logger.info("acquired lock with id " + lockId);
+ logger.info(EELFLoggerDelegate.applicationLogger,"acquired lock with id " + lockId);
MusicCore.pureZkWrite(lockname, data);
zkPutTime = System.currentTimeMillis();
boolean voluntaryRelease = true;
- if (consistency.equals("atomic"))
+ if (("atomic").equals(consistency))
MusicCore.releaseLock(lockId, voluntaryRelease);
- else if (consistency.equals("atomic_delete_lock"))
+ else if (("atomic_delete_lock").equals(consistency))
MusicCore.deleteLock(lockname);
lockReleaseTime = System.currentTimeMillis();
} else {
+ "|lock accquire time:" + (lockAcqTime - lockCreationTime)
+ "|zk put time:" + (zkPutTime - lockAcqTime);
- if (consistency.equals("atomic"))
+ if ("atomic".equals(consistency))
lockingInfo = lockingInfo + "|lock release time:" + (lockReleaseTime - zkPutTime) + "|";
- else if (consistency.equals("atomic_delete_lock"))
+ else if ("atomic_delete_lock".equals(consistency))
lockingInfo = lockingInfo + "|lock delete time:" + (lockReleaseTime - zkPutTime) + "|";
- String timingString = "Time taken in ms for Zookeeper " + consistency + " update-"
+ String timingString = "Time taken in ms for Zookeeper " + consistency + UPDATE_CONST
+ operationId + ":" + "|total operation time:" + (endTime - startTime)
+ "|json parsing time:" + (jsonParseCompletionTime - startTime)
+ "|update time:" + (actualUpdateCompletionTime - jsonParseCompletionTime)
+ lockingInfo;
- logger.info(timingString);
+ logger.info(EELFLoggerDelegate.applicationLogger,timingString);
}
/**
}
long end = System.currentTimeMillis();
- logger.info("Total time taken for Zk atomic read:" + (end - start) + " ms");
+ logger.info(EELFLoggerDelegate.applicationLogger,"Total time taken for Zk atomic read:" + (end - start) + " ms");
}
/**
long startTime = System.currentTimeMillis();
String operationId = UUID.randomUUID().toString();// just for debugging purposes.
String consistency = insObj.getConsistencyInfo().get("type");
- logger.info("--------------Cassandra " + consistency + " update-" + operationId
+ logger.info(EELFLoggerDelegate.applicationLogger,"--------------Cassandra " + consistency + UPDATE_CONST + operationId
+ "-------------------------");
PreparedQueryObject queryObject = new PreparedQueryObject();
Map<String, Object> valuesMap = insObj.getValues();
if ((ttl != null) && (timestamp != null)) {
- logger.info("both there");
+ logger.info(EELFLoggerDelegate.applicationLogger,"both there");
queryObject.appendQueryString(" USING TTL ? AND TIMESTAMP ?");
queryObject.addValue(Integer.parseInt(ttl));
queryObject.addValue(Long.parseLong(timestamp));
}
if ((ttl != null) && (timestamp == null)) {
- logger.info("ONLY TTL there");
+ logger.info(EELFLoggerDelegate.applicationLogger,"ONLY TTL there");
queryObject.appendQueryString(" USING TTL ?");
queryObject.addValue(Integer.parseInt(ttl));
}
if ((ttl == null) && (timestamp != null)) {
- logger.info("ONLY timestamp there");
+ logger.info(EELFLoggerDelegate.applicationLogger,"ONLY timestamp there");
queryObject.appendQueryString(" USING TIMESTAMP ?");
queryObject.addValue(Long.parseLong(timestamp));
}
long endTime = System.currentTimeMillis();
- String timingString = "Time taken in ms for Cassandra " + consistency + " update-"
+ String timingString = "Time taken in ms for Cassandra " + consistency + UPDATE_CONST
+ operationId + ":" + "|total operation time:" + (endTime - startTime)
+ "|json parsing time:" + (jsonParseCompletionTime - startTime)
+ "|update time:" + (actualUpdateCompletionTime - jsonParseCompletionTime)
+ "|";
- logger.info(timingString);
+ logger.info(EELFLoggerDelegate.applicationLogger,timingString);
return operationResult;
}
-
}