diff --git a/pom.xml b/pom.xml
index 70c003e9b420e92e111eb1baf2377cf3f6e94127..1913854a61afaabf4615b038b078e9b827dd76d6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,13 +8,13 @@
2.0-2016
+ skywalking-commons
skywalking-alarm
skywalking-webui
skywalking-sniffer
skywalking-storage-center
samples/skywalking-auth
samples/skywalking-example
- skywalking-commons
pom
@@ -23,7 +23,6 @@
UTF-8
- 2.0-2016
diff --git a/skywalking-commons/pom.xml b/skywalking-commons/pom.xml
index 5f0e50b92883fbabf8301ceae28739832ca565ac..9cae90dffb797878b94ceac2bf31382f48814293 100644
--- a/skywalking-commons/pom.xml
+++ b/skywalking-commons/pom.xml
@@ -21,6 +21,18 @@
UTF-8
- 2.0-2016
+
+
+
+
+ maven-compiler-plugin
+
+
+ 1.6
+ ${project.build.sourceEncoding}
+
+
+
+
diff --git a/skywalking-commons/skywalking-health-report/pom.xml b/skywalking-commons/skywalking-health-report/pom.xml
index a229641f77567f03ea0d6e50a59c4982630a1697..506f134220589222a658392a7a35ba4beb2b65dc 100644
--- a/skywalking-commons/skywalking-health-report/pom.xml
+++ b/skywalking-commons/skywalking-health-report/pom.xml
@@ -17,7 +17,7 @@
com.a.eye
skywalking-logging-api
- 2.0-2016
+ ${project.version}
diff --git a/skywalking-commons/skywalking-health-report/src/main/java/com/a/eye/skywalking/health/report/HealthCollector.java b/skywalking-commons/skywalking-health-report/src/main/java/com/a/eye/skywalking/health/report/HealthCollector.java
index d010d98f3714c30f763c6235f20c6936966e0346..e26bb761ab4b8604459be36f81b30eef00462bb2 100644
--- a/skywalking-commons/skywalking-health-report/src/main/java/com/a/eye/skywalking/health/report/HealthCollector.java
+++ b/skywalking-commons/skywalking-health-report/src/main/java/com/a/eye/skywalking/health/report/HealthCollector.java
@@ -1,7 +1,6 @@
package com.a.eye.skywalking.health.report;
-import com.a.eye.skywalking.health.report.util.MachineUtil;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
@@ -10,15 +9,15 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class HealthCollector extends Thread {
- private static ILog logger =
- LogManager.getLogger(HealthCollector.class);
- private static Map heathReadings =
- new ConcurrentHashMap();
+ private static ILog logger = LogManager.getLogger(HealthCollector.class);
+ private static Map heathReadings = new ConcurrentHashMap();
private static final long DEFAULT_REPORT_INTERVAL = 60 * 1000;
- private final long reportInterval;
+ private final long reportInterval;
+ private String reporterName;
- private HealthCollector() {
+ private HealthCollector(String reporterName) {
this(DEFAULT_REPORT_INTERVAL);
+ this.reporterName = reporterName;
}
private HealthCollector(long reportInterval) {
@@ -27,8 +26,8 @@ public class HealthCollector extends Thread {
this.reportInterval = reportInterval;
}
- public static void init() {
- new HealthCollector().start();
+ public static void init(String reporterName) {
+ new HealthCollector(reporterName).start();
}
public static HeathReading getCurrentHeathReading(String extraId) {
@@ -37,8 +36,7 @@ public class HealthCollector extends Thread {
synchronized (heathReadings) {
if (!heathReadings.containsKey(id)) {
if (heathReadings.keySet().size() > 5000) {
- throw new RuntimeException(
- "use HealthCollector illegal. There is an overflow trend of Server Health Collector Report Data.");
+ throw new RuntimeException("use HealthCollector illegal. There is an overflow trend of Server Health Collector Report Data.");
}
heathReadings.put(id, new HeathReading(id));
}
@@ -48,8 +46,7 @@ public class HealthCollector extends Thread {
}
private static String getId(String extraId) {
- return "SkyWalking Health Report,P:" + MachineUtil.getProcessNo() + ",T:" + Thread.currentThread().getName()
- + "(" + Thread.currentThread().getId() + ")" + (extraId == null ? "" : ",extra:" + extraId);
+ return "T:" + Thread.currentThread().getName() + "(" + Thread.currentThread().getId() + ")" + (extraId == null ? "" : ",extra:" + extraId);
}
@Override
@@ -61,7 +58,7 @@ public class HealthCollector extends Thread {
String[] keyList = heathReadingsSnapshot.keySet().toArray(new String[0]);
Arrays.sort(keyList);
StringBuilder log = new StringBuilder();
- log.append("\n---------Server Health Collector Report---------\n");
+ log.append("\n---------" + reporterName + " Health Report---------\n");
for (String key : keyList) {
log.append(heathReadingsSnapshot.get(key)).append("\n");
}
diff --git a/skywalking-commons/skywalking-health-report/src/main/java/com/a/eye/skywalking/health/report/util/MachineUtil.java b/skywalking-commons/skywalking-health-report/src/main/java/com/a/eye/skywalking/health/report/util/MachineUtil.java
deleted file mode 100644
index 63f65c01ae111daa9cb8182daad79d168b4c70c2..0000000000000000000000000000000000000000
--- a/skywalking-commons/skywalking-health-report/src/main/java/com/a/eye/skywalking/health/report/util/MachineUtil.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.a.eye.skywalking.health.report.util;
-
-import java.lang.management.ManagementFactory;
-
-/**
- * Created by xin on 2016/11/14.
- */
-
-public class MachineUtil {
- private static String processNo;
-
- static {
- processNo = getProcessNo();
- }
-
- public static String getProcessNo() {
- if (processNo == null) {
- String name = ManagementFactory.getRuntimeMXBean().getName();
- processNo = name.split("@")[0];
- }
- return processNo;
- }
-
- private MachineUtil() {
- // Non
- }
-}
diff --git a/skywalking-commons/skywalking-registry/pom.xml b/skywalking-commons/skywalking-registry/pom.xml
index 88e67cf3b82927790a4e279c7d33cb7dfe998f56..0e344b44b7e806aaa0088303a34915f3ed64290a 100644
--- a/skywalking-commons/skywalking-registry/pom.xml
+++ b/skywalking-commons/skywalking-registry/pom.xml
@@ -18,20 +18,20 @@
-
- org.apache.zookeeper
- zookeeper
- 3.4.8
-
com.a.eye
skywalking-logging-api
- 2.0-2016
+ ${project.version}
com.a.eye
skywalking-logging-impl-log4j2
- 2.0-2016
+ ${project.version}
+
+
+ org.apache.zookeeper
+ zookeeper
+ 3.4.8
diff --git a/skywalking-storage-center/pom.xml b/skywalking-storage-center/pom.xml
index 0a5ed77d96866c6a77c8b90d0fa00fb9161b4951..0718f445c005110345de2e98acb5c4eaa27a90da 100644
--- a/skywalking-storage-center/pom.xml
+++ b/skywalking-storage-center/pom.xml
@@ -24,11 +24,15 @@
skywalking-logging
${parent.version}
-
com.a.eye
skywalking-network
${parent.version}
+
+ com.a.eye
+ data-carrier
+ 1.1
+
diff --git a/skywalking-storage-center/skywalking-storage/pom.xml b/skywalking-storage-center/skywalking-storage/pom.xml
index 8939995fcffef60c80371113383bf41011f2ce38..ff43abc84259593696280b973fa38b74d77a1a87 100644
--- a/skywalking-storage-center/skywalking-storage/pom.xml
+++ b/skywalking-storage-center/skywalking-storage/pom.xml
@@ -17,17 +17,17 @@
com.a.eye
- skywalking-network
+ skywalking-registry
${project.version}
com.a.eye
- skywalking-registry
- 2.0-2016
+ skywalking-logging-impl-log4j2
+ ${project.version}
com.a.eye
- skywalking-logging-impl-log4j2
+ skywalking-health-report
${project.version}
@@ -35,27 +35,12 @@
hsqldb
2.3.4
-
- com.a.eye
- data-carrier
- 1.0
-
-
-
- com.a.eye
- skywalking-registry
- ${project.version}
-
com.zaxxer
HikariCP
2.4.3
-
- com.a.eye
- skywalking-health-report
- 2.0-2016
-
+
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/Main.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/Main.java
index 3cc27ba63da5b24b3b6298e010b20ea9ceb34cdf..f658a209941832b0bb6ad542ea667f7af4bdbfc3 100644
--- a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/Main.java
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/Main.java
@@ -29,7 +29,8 @@ import static com.a.eye.skywalking.storage.config.Config.RegistryCenter.PATH_PRE
*/
public class Main {
- private static ILog logger = LogManager.getLogger(Main.class);
+ private static final ILog logger = LogManager.getLogger(Main.class);
+ private static final String SERVER_REPORTER_NAME = "Storage Server";
static {
LogManager.setLogResolver(new Log4j2Resolver());
@@ -41,7 +42,7 @@ public class Main {
try {
initializeParam();
- HealthCollector.init();
+ HealthCollector.init(SERVER_REPORTER_NAME);
DataFilesManager.init();
@@ -54,15 +55,15 @@ public class Main {
provider.start();
if (logger.isDebugEnable()) {
- logger.debug("Service provider started successfully.");
+ logger.debug("Service provider started.");
}
registryNode();
- logger.info("Storage service started successfully.");
+ logger.info("SkyWalking storage server started.");
Thread.currentThread().join();
} catch (Throwable e) {
- logger.error("Failed to start service.", e);
+ logger.error("SkyWalking storage server start failure.", e);
} finally {
provider.stop();
IndexDataCapacityMonitor.stop();
@@ -88,10 +89,10 @@ public class Main {
printStorageConfig(properties);
ConfigInitializer.initialize(properties, Config.class);
} catch (IllegalAccessException e) {
- logger.error("Initialize the collect server configuration failed", e);
+ logger.error("Initialize server configuration failure.", e);
throw e;
} catch (IOException e) {
- logger.error("Initialize the collect server configuration failed", e);
+ logger.error("Initialize server configuration failure.", e);
throw e;
}
}
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/SpanDataConsumer.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/SpanDataConsumer.java
index 9fc064f1569329fe388d950f583665a565a54fd7..edd650235126acf25951f2443e926a837112422a 100644
--- a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/SpanDataConsumer.java
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/SpanDataConsumer.java
@@ -53,4 +53,10 @@ public class SpanDataConsumer implements IConsumer {
HealthCollector.getCurrentHeathReading("SpanDataConsumer").updateData(HeathReading.ERROR,
"Failed to consume span data. error message : " + throwable.getMessage());
}
+
+ @Override
+ public void onExit() {
+ cache.close();
+ fileWriter.close();
+ }
}
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/SpanDataFinder.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/SpanDataFinder.java
index 62110905b45e6ff477795c8f9d1cf33245389dad..c2501ce7bab43da3a0cc7f4e8ffb8b17f9a46b5f 100644
--- a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/SpanDataFinder.java
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/SpanDataFinder.java
@@ -5,6 +5,7 @@ import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.storage.block.index.BlockIndexEngine;
import com.a.eye.skywalking.storage.config.Config;
import com.a.eye.skywalking.storage.config.Constants;
+import com.a.eye.skywalking.storage.data.exception.ConnectionNotFoundException;
import com.a.eye.skywalking.storage.data.file.DataFileReader;
import com.a.eye.skywalking.storage.data.index.*;
import com.a.eye.skywalking.storage.data.spandata.SpanData;
@@ -13,15 +14,16 @@ import com.zaxxer.hikari.HikariDataSource;
import java.sql.SQLException;
import java.util.*;
+import java.util.concurrent.locks.ReentrantLock;
import static com.a.eye.skywalking.storage.config.Constants.SQL.DEFAULT_PASSWORD;
import static com.a.eye.skywalking.storage.config.Constants.SQL.DEFAULT_USER;
import static com.a.eye.skywalking.storage.util.PathResolver.getAbsolutePath;
public class SpanDataFinder {
- private static ILog logger = LogManager.getLogger(SpanDataFinder.class);
- private static IndexDataSourceCache datasourceCache =
- new IndexDataSourceCache(Config.Finder.CACHED_SIZE);
+ private static ILog logger = LogManager.getLogger(SpanDataFinder.class);
+ private static IndexDataSourceCache datasourceCache = new IndexDataSourceCache(Config.Finder.CACHED_SIZE);
+ private static ReentrantLock createDatasourceLock = new ReentrantLock();
public static List find(String traceId) {
long blockIndex = BlockIndexEngine.newFinder().find(fetchStartTimeFromTraceId(traceId));
@@ -29,22 +31,40 @@ public class SpanDataFinder {
return new ArrayList();
}
- IndexDBConnector indexDBConnector = fetchIndexDBConnector(blockIndex);
- IndexMetaCollection indexMetaCollection = indexDBConnector.queryByTraceId(traceId);
- indexDBConnector.close();
+ IndexDBConnector indexDBConnector = null;
+ IndexMetaCollection indexMetaCollection = null;
+ try {
+ indexDBConnector = fetchIndexDBConnector(blockIndex);
+ indexMetaCollection = indexDBConnector.queryByTraceId(traceId);
+ } finally {
+ if (indexDBConnector != null) {
+ indexDBConnector.close();
+ }
+ }
- Iterator> iterator =
- IndexMetaCollections.group(indexMetaCollection, new GroupKeyBuilder() {
- @Override
- public String buildKey(IndexMetaInfo metaInfo) {
- return metaInfo.getFileName();
- }
- }).iterator();
+ if (indexMetaCollection == null) {
+ return new ArrayList();
+ }
+
+ Iterator> iterator = IndexMetaCollections.group(indexMetaCollection, new GroupKeyBuilder() {
+ @Override
+ public String buildKey(IndexMetaInfo metaInfo) {
+ return metaInfo.getFileName();
+ }
+ }).iterator();
List result = new ArrayList();
while (iterator.hasNext()) {
IndexMetaGroup group = iterator.next();
- result.addAll(new DataFileReader(group.getKey()).read(group.getMetaInfo()));
+ DataFileReader reader = null;
+ try {
+ reader = new DataFileReader(group.getKey());
+ result.addAll(reader.read(group.getMetaInfo()));
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
}
return result;
@@ -52,12 +72,11 @@ public class SpanDataFinder {
private static IndexDBConnector fetchIndexDBConnector(long blockIndex) {
HikariDataSource datasource = getOrCreate(blockIndex);
- IndexDBConnector indexDBConnector = null;
+ IndexDBConnector indexDBConnector;
try {
indexDBConnector = new IndexDBConnector(datasource.getConnection());
} catch (SQLException e) {
- logger.warn("Failed to get connection from datasource,", e);
- indexDBConnector = new IndexDBConnector(blockIndex);
+ throw new ConnectionNotFoundException("get connection failure.", e);
}
return indexDBConnector;
}
@@ -65,17 +84,23 @@ public class SpanDataFinder {
private static HikariDataSource getOrCreate(long blockIndex) {
HikariDataSource datasource = datasourceCache.get(blockIndex);
if (datasource == null) {
- HikariConfig dataSourceConfig = generateDatasourceConfig(blockIndex);
- datasource = new HikariDataSource(dataSourceConfig);
- datasourceCache.put(blockIndex, datasource);
+ createDatasourceLock.lock();
+ try {
+ if (datasource == null) {
+ HikariConfig dataSourceConfig = generateDatasourceConfig(blockIndex);
+ datasource = new HikariDataSource(dataSourceConfig);
+ datasourceCache.put(blockIndex, datasource);
+ }
+ } finally {
+ createDatasourceLock.unlock();
+ }
}
return datasource;
}
private static HikariConfig generateDatasourceConfig(long blockIndex) {
HikariConfig config = new HikariConfig();
- config.setJdbcUrl(new ConnectURLGenerator(getAbsolutePath(Config.DataIndex.PATH),
- Config.DataIndex.FILE_NAME).generate(blockIndex));
+ config.setJdbcUrl(new ConnectURLGenerator(getAbsolutePath(Config.DataIndex.PATH), Config.DataIndex.FILE_NAME).generate(blockIndex));
config.setDriverClassName(Constants.DRIVER_CLASS_NAME);
config.setUsername(DEFAULT_USER);
config.setPassword(DEFAULT_PASSWORD);
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/ConnectionNotFoundException.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/ConnectionNotFoundException.java
new file mode 100644
index 0000000000000000000000000000000000000000..393d01ec1a7d4b01552774656364e87939ad2763
--- /dev/null
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/ConnectionNotFoundException.java
@@ -0,0 +1,10 @@
+package com.a.eye.skywalking.storage.data.exception;
+
+/**
+ * Created by xin on 2016/11/5.
+ */
+public class ConnectionNotFoundException extends RuntimeException {
+ public ConnectionNotFoundException(String message, Exception e) {
+ super(message, e);
+ }
+}
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/IndexMetaPersistenceFailedException.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/IndexMetaPersistenceFailedException.java
deleted file mode 100644
index 17acbaf89959c7e3e453c0b22ddedeaa91c5ae6f..0000000000000000000000000000000000000000
--- a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/IndexMetaPersistenceFailedException.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.a.eye.skywalking.storage.data.exception;
-
-public class IndexMetaPersistenceFailedException extends RuntimeException {
- public IndexMetaPersistenceFailedException(String message, Exception e){
- super(message, e);
- }
-}
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/IndexMetaStoredFailedException.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/IndexMetaStoredFailedException.java
new file mode 100644
index 0000000000000000000000000000000000000000..37ca808a68ec7ee9dafa2c7ea17f2d17413d7b6b
--- /dev/null
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/IndexMetaStoredFailedException.java
@@ -0,0 +1,7 @@
+package com.a.eye.skywalking.storage.data.exception;
+
+public class IndexMetaStoredFailedException extends RuntimeException {
+ public IndexMetaStoredFailedException(String message, Exception e){
+ super(message, e);
+ }
+}
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/SpanDataPersistenceFailedException.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/SpanDataPersistenceFailedException.java
deleted file mode 100644
index 07956c34ee8512f1435a179d9803f4f6292037da..0000000000000000000000000000000000000000
--- a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/SpanDataPersistenceFailedException.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.a.eye.skywalking.storage.data.exception;
-
-/**
- * Created by xin on 2016/11/4.
- */
-public class SpanDataPersistenceFailedException extends RuntimeException {
- public SpanDataPersistenceFailedException(Exception e) {
- }
-}
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/SpanDataStoredFailedException.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/SpanDataStoredFailedException.java
new file mode 100644
index 0000000000000000000000000000000000000000..3eeda44a7b67758a6489a8eb8fd4af3ae4912ecf
--- /dev/null
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/exception/SpanDataStoredFailedException.java
@@ -0,0 +1,9 @@
+package com.a.eye.skywalking.storage.data.exception;
+
+/**
+ * Created by xin on 2016/11/4.
+ */
+public class SpanDataStoredFailedException extends RuntimeException {
+ public SpanDataStoredFailedException(Exception e) {
+ }
+}
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFile.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFile.java
index e005a85d681df365b3acca1fff455921e4cd1842..9721663fea97062757681b49af08028fd8c841cd 100644
--- a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFile.java
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFile.java
@@ -4,7 +4,7 @@ import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.storage.config.Config;
import com.a.eye.skywalking.storage.data.exception.DataFileOperatorCreateFailedException;
-import com.a.eye.skywalking.storage.data.exception.SpanDataPersistenceFailedException;
+import com.a.eye.skywalking.storage.data.exception.SpanDataStoredFailedException;
import com.a.eye.skywalking.storage.data.exception.SpanDataReadFailedException;
import com.a.eye.skywalking.storage.data.index.IndexMetaInfo;
import com.a.eye.skywalking.storage.data.spandata.SpanData;
@@ -84,7 +84,7 @@ public class DataFile {
currentOffset += bytes.length;
return metaInfo;
} catch (IOException e) {
- throw new SpanDataPersistenceFailedException(e);
+ throw new SpanDataStoredFailedException(e);
}
}
@@ -92,10 +92,14 @@ public class DataFile {
try {
operator.getWriter().flush();
} catch (IOException e) {
- throw new SpanDataPersistenceFailedException(e);
+ throw new SpanDataStoredFailedException(e);
}
}
+ public void close(){
+ operator.close();
+ }
+
public byte[] read(long offset, int length) {
byte[] data = new byte[length];
try {
@@ -103,8 +107,7 @@ public class DataFile {
operator.getReader().read(data, 0, length);
return data;
} catch (IOException e) {
- throw new SpanDataReadFailedException(
- "Failed to read dataFile[" + fileName + "], offset: " + offset + " " + "lenght: " + length, e);
+ throw new SpanDataReadFailedException("Failed to read dataFile[" + fileName + "], offset: " + offset + " " + "lenght: " + length, e);
}
}
@@ -136,6 +139,23 @@ public class DataFile {
return reader;
}
+
+ public void close() {
+ if (writer != null) {
+ try {
+ writer.close();
+ } catch (IOException e) {
+
+ }
+ }
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e) {
+
+ }
+ }
+ }
}
private File getDataFile() {
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFileReader.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFileReader.java
index 34b6836e52bd06e381dfb30e5c9de0bbfa98e40d..d40ae2a3a70af2ff6cc04a040b88317c6a444497 100644
--- a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFileReader.java
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFileReader.java
@@ -47,4 +47,8 @@ public class DataFileReader {
return metaData;
}
+
+ public void close(){
+ dataFile.close();
+ }
}
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFileWriter.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFileWriter.java
index 0b2587cf20ff82f97fe5c70966985af8f1c680d6..d818cf04a02866abfd117cd79d27f75957ac730e 100644
--- a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFileWriter.java
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/file/DataFileWriter.java
@@ -15,6 +15,7 @@ public class DataFileWriter {
public IndexMetaCollection write(List spanData) {
if (dataFile.overLimitLength()) {
+ this.close();
dataFile = DataFilesManager.createNewDataFile();
}
@@ -26,4 +27,8 @@ public class DataFileWriter {
return collections;
}
+
+ public void close(){
+ dataFile.close();
+ }
}
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/index/IndexDBConnectorCache.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/index/IndexDBConnectorCache.java
index 589c826d14e2cac6848ec15c65e810b20a3ee94b..1d85a1c62f735ac4990362db4eee96dec9443090 100644
--- a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/index/IndexDBConnectorCache.java
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/index/IndexDBConnectorCache.java
@@ -22,6 +22,10 @@ public class IndexDBConnectorCache {
return connector;
}
+ public void close(){
+ cachedOperators.close();
+ }
+
private void updateCache(long timestamp, IndexDBConnector operator) {
cachedOperators.put(timestamp, operator);
}
@@ -43,5 +47,11 @@ public class IndexDBConnectorCache {
public LRUCache(int cacheSize) {
super((int) Math.ceil(cacheSize / 0.75) + 1, 0.75f, true);
}
+
+ public void close(){
+ for(Map.Entry entry : this.entrySet()){
+ entry.getValue().close();
+ }
+ }
}
}
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/index/IndexOperator.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/index/IndexOperator.java
index 9770ebf5be3df9a98e84219bbdefa323539164ab..748d5c128725ba555b1ae709a7519ac97d3da915 100644
--- a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/index/IndexOperator.java
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/data/index/IndexOperator.java
@@ -1,10 +1,7 @@
package com.a.eye.skywalking.storage.data.index;
import com.a.eye.skywalking.storage.data.IndexDataCapacityMonitor;
-import com.a.eye.skywalking.storage.data.exception.IndexMetaPersistenceFailedException;
-
-import java.util.ArrayList;
-import java.util.List;
+import com.a.eye.skywalking.storage.data.exception.IndexMetaStoredFailedException;
public class IndexOperator {
@@ -21,7 +18,7 @@ public class IndexOperator {
connector.batchUpdate(metaGroup);
IndexDataCapacityMonitor.addIndexData(timestamp, metaGroup.size());
} catch (Exception e) {
- throw new IndexMetaPersistenceFailedException("Failed to batch save index meta", e);
+ throw new IndexMetaStoredFailedException("Failed to batch save index meta", e);
}
}
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/listener/SearchListener.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/listener/SearchListener.java
index dab422fdfa7eb9aab59d483a936e2f3d0b4a08c0..bbb0ae63fc89ae70fc929968dff7a150aa2ef2cf 100644
--- a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/listener/SearchListener.java
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/listener/SearchListener.java
@@ -24,12 +24,12 @@ public class SearchListener implements TraceSearchListener {
SpanDataHelper helper = new SpanDataHelper(data);
List span = helper.category().mergeData();
HealthCollector.getCurrentHeathReading("SearchListener")
- .updateData(HeathReading.INFO, span.size() + " spans was founded by trace Id [" + traceId + "].");
+ .updateData(HeathReading.INFO, span.size() + " spans was found by trace Id [" + traceId + "].");
return span;
} catch (Exception e) {
- logger.error("Failed to search trace Id [{}]", traceId, e);
+ logger.error("Search trace Id[{}] failure.", traceId, e);
HealthCollector.getCurrentHeathReading("SearchListener")
- .updateData(HeathReading.ERROR, "Failed to search trace Id" + traceId + ".");
+ .updateData(HeathReading.ERROR, "Search trace Id[" + traceId + "] failure.");
return new ArrayList();
}
}
diff --git a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/listener/StorageListener.java b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/listener/StorageListener.java
index 90aad32e2cf5ce4413c5bb52858a26c5f4b119d2..bc24ff6c7fa3f44732bad05ad8796e5a3fa5eb0a 100644
--- a/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/listener/StorageListener.java
+++ b/skywalking-storage-center/skywalking-storage/src/main/java/com/a/eye/skywalking/storage/listener/StorageListener.java
@@ -28,13 +28,11 @@ public class StorageListener implements SpanStorageListener {
public boolean storage(RequestSpan requestSpan) {
try {
spanDataDataCarrier.produce(SpanDataBuilder.build(requestSpan));
- HealthCollector.getCurrentHeathReading("StorageListener").updateData(HeathReading.INFO,"Request span "
- + "consume successfully");
+ HealthCollector.getCurrentHeathReading("StorageListener").updateData(HeathReading.INFO,"RequestSpan stored.");
return true;
} catch (Exception e) {
- logger.error("Failed to storage request span. Span Data:\n {}.", requestSpan.toByteString(), e);
- HealthCollector.getCurrentHeathReading("StorageListener").updateData(HeathReading.ERROR,"Request span "
- + "consume failed");
+ logger.error("RequestSpan trace-id[{}] store failure..", requestSpan.getTraceId(), e);
+ HealthCollector.getCurrentHeathReading("StorageListener").updateData(HeathReading.ERROR,"RequestSpan store failure.");
return false;
}
}
@@ -43,9 +41,11 @@ public class StorageListener implements SpanStorageListener {
public boolean storage(AckSpan ackSpan) {
try {
spanDataDataCarrier.produce(SpanDataBuilder.build(ackSpan));
+ HealthCollector.getCurrentHeathReading("StorageListener").updateData(HeathReading.INFO,"AckSpan stored.");
return true;
} catch (Exception e) {
- logger.error("Failed to storage ack span. ack Data:\n {}.", ackSpan.toByteString(), e);
+ logger.error("AckSpan trace-id[{}] store failure..", ackSpan.getTraceId(), e);
+ HealthCollector.getCurrentHeathReading("StorageListener").updateData(HeathReading.ERROR,"AckSpan store failure.");
return false;
}
}