Add the implements of naming module.
This commit is contained in:
parent
5828f286b9
commit
e414570039
|
|
@ -21,5 +21,5 @@ package org.skywalking.apm.collector.core.framework;
|
|||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface Handler {
|
||||
public interface ServerHandler {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package org.skywalking.apm.collector.cluster;
|
||||
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleRegisterService;
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleRegistrationGetService;
|
||||
import org.skywalking.apm.collector.core.module.Module;
|
||||
import org.skywalking.apm.collector.core.module.Service;
|
||||
|
||||
|
|
@ -34,6 +35,6 @@ public class ClusterModule extends Module {
|
|||
}
|
||||
|
||||
@Override public Class<? extends Service>[] services() {
|
||||
return new Class[] {ModuleRegisterService.class};
|
||||
return new Class[] {ModuleRegisterService.class, ModuleRegistrationGetService.class};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.cluster.service;
|
||||
|
||||
import java.util.Set;
|
||||
import org.skywalking.apm.collector.core.module.Service;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface ModuleRegistrationGetService extends Service {
|
||||
Set<String> get(String path);
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@ package org.skywalking.apm.collector.cluster.redis;
|
|||
import java.util.Properties;
|
||||
import org.skywalking.apm.collector.cluster.ClusterModule;
|
||||
import org.skywalking.apm.collector.cluster.redis.service.RedisModuleRegisterService;
|
||||
import org.skywalking.apm.collector.cluster.redis.service.RedisModuleRegistrationGetService;
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleRegisterService;
|
||||
import org.skywalking.apm.collector.core.module.Module;
|
||||
import org.skywalking.apm.collector.core.module.ModuleProvider;
|
||||
|
|
@ -41,6 +42,7 @@ public class ClusterModuleRedisProvider extends ModuleProvider {
|
|||
|
||||
@Override public void prepare(Properties config) throws ServiceNotProvidedException {
|
||||
this.registerServiceImplementation(ModuleRegisterService.class, new RedisModuleRegisterService());
|
||||
this.registerServiceImplementation(ModuleRegisterService.class, new RedisModuleRegistrationGetService());
|
||||
}
|
||||
|
||||
@Override public void init(Properties config) throws ServiceNotProvidedException {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.cluster.redis.service;
|
||||
|
||||
import java.util.Set;
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleRegistrationGetService;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class RedisModuleRegistrationGetService implements ModuleRegistrationGetService {
|
||||
|
||||
@Override public Set<String> get(String path) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@ import java.util.Properties;
|
|||
import org.skywalking.apm.collector.cluster.ClusterModule;
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleRegisterService;
|
||||
import org.skywalking.apm.collector.cluster.standalone.service.StandaloneModuleRegisterService;
|
||||
import org.skywalking.apm.collector.cluster.standalone.service.StandaloneModuleRegistrationGetService;
|
||||
import org.skywalking.apm.collector.core.module.Module;
|
||||
import org.skywalking.apm.collector.core.module.ModuleProvider;
|
||||
import org.skywalking.apm.collector.core.module.ServiceNotProvidedException;
|
||||
|
|
@ -41,6 +42,7 @@ public class ClusterModuleStandaloneProvider extends ModuleProvider {
|
|||
|
||||
@Override public void prepare(Properties config) throws ServiceNotProvidedException {
|
||||
this.registerServiceImplementation(ModuleRegisterService.class, new StandaloneModuleRegisterService());
|
||||
this.registerServiceImplementation(ModuleRegisterService.class, new StandaloneModuleRegistrationGetService());
|
||||
}
|
||||
|
||||
@Override public void init(Properties config) throws ServiceNotProvidedException {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.cluster.standalone.service;
|
||||
|
||||
import java.util.Set;
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleRegistrationGetService;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class StandaloneModuleRegistrationGetService implements ModuleRegistrationGetService {
|
||||
|
||||
@Override public Set<String> get(String path) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,8 @@ package org.skywalking.apm.collector.cluster.zookeeper;
|
|||
import java.util.Properties;
|
||||
import org.skywalking.apm.collector.cluster.ClusterModule;
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleRegisterService;
|
||||
import org.skywalking.apm.collector.cluster.zookeeper.service.ZKModuleRegisterService;
|
||||
import org.skywalking.apm.collector.cluster.zookeeper.service.ZookeeperModuleRegisterService;
|
||||
import org.skywalking.apm.collector.cluster.zookeeper.service.ZookeeperModuleRegistrationGetService;
|
||||
import org.skywalking.apm.collector.core.module.Module;
|
||||
import org.skywalking.apm.collector.core.module.ModuleProvider;
|
||||
import org.skywalking.apm.collector.core.module.ServiceNotProvidedException;
|
||||
|
|
@ -29,7 +30,7 @@ import org.skywalking.apm.collector.core.module.ServiceNotProvidedException;
|
|||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ClusterModuleZKProvider extends ModuleProvider {
|
||||
public class ClusterModuleZookeeperProvider extends ModuleProvider {
|
||||
|
||||
@Override public String name() {
|
||||
return "zookeeper";
|
||||
|
|
@ -40,7 +41,8 @@ public class ClusterModuleZKProvider extends ModuleProvider {
|
|||
}
|
||||
|
||||
@Override public void prepare(Properties config) throws ServiceNotProvidedException {
|
||||
this.registerServiceImplementation(ModuleRegisterService.class, new ZKModuleRegisterService());
|
||||
this.registerServiceImplementation(ModuleRegisterService.class, new ZookeeperModuleRegisterService());
|
||||
this.registerServiceImplementation(ModuleRegisterService.class, new ZookeeperModuleRegistrationGetService());
|
||||
}
|
||||
|
||||
@Override public void init(Properties config) throws ServiceNotProvidedException {
|
||||
|
|
@ -23,5 +23,5 @@ import org.skywalking.apm.collector.cluster.service.ModuleRegisterService;
|
|||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ZKModuleRegisterService implements ModuleRegisterService {
|
||||
public class ZookeeperModuleRegisterService implements ModuleRegisterService {
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.cluster.zookeeper.service;
|
||||
|
||||
import java.util.Set;
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleRegistrationGetService;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ZookeeperModuleRegistrationGetService implements ModuleRegistrationGetService {
|
||||
@Override public Set<String> get(String path) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,4 +16,4 @@
|
|||
# Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
#
|
||||
|
||||
org.skywalking.apm.collector.cluster.zookeeper.ClusterModuleZKProvider
|
||||
org.skywalking.apm.collector.cluster.zookeeper.ClusterModuleZookeeperProvider
|
||||
|
|
@ -38,8 +38,8 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.transport.client.PreBuiltTransportClient;
|
||||
import org.skywalking.apm.collector.core.client.Client;
|
||||
import org.skywalking.apm.collector.core.client.ClientException;
|
||||
import org.skywalking.apm.collector.core.component.client.Client;
|
||||
import org.skywalking.apm.collector.core.component.client.ClientException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.skywalking.apm.collector.client.elasticsearch;
|
||||
|
||||
import org.skywalking.apm.collector.core.client.ClientException;
|
||||
import org.skywalking.apm.collector.core.component.client.ClientException;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ package org.skywalking.apm.collector.client.grpc;
|
|||
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.ManagedChannelBuilder;
|
||||
import org.skywalking.apm.collector.core.client.Client;
|
||||
import org.skywalking.apm.collector.core.client.ClientException;
|
||||
import org.skywalking.apm.collector.core.component.client.Client;
|
||||
import org.skywalking.apm.collector.core.component.client.ClientException;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.skywalking.apm.collector.client.grpc;
|
||||
|
||||
import org.skywalking.apm.collector.core.client.ClientException;
|
||||
import org.skywalking.apm.collector.core.component.client.ClientException;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import org.h2.util.IOUtils;
|
||||
import org.skywalking.apm.collector.core.client.Client;
|
||||
import org.skywalking.apm.collector.core.component.client.Client;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.skywalking.apm.collector.client.h2;
|
||||
|
||||
import org.skywalking.apm.collector.core.client.ClientException;
|
||||
import org.skywalking.apm.collector.core.component.client.ClientException;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
package org.skywalking.apm.collector.client.redis;
|
||||
|
||||
import org.skywalking.apm.collector.core.client.Client;
|
||||
import org.skywalking.apm.collector.core.client.ClientException;
|
||||
import org.skywalking.apm.collector.core.component.client.Client;
|
||||
import org.skywalking.apm.collector.core.component.client.ClientException;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.skywalking.apm.collector.client.redis;
|
||||
|
||||
import org.skywalking.apm.collector.core.client.ClientException;
|
||||
import org.skywalking.apm.collector.core.component.client.ClientException;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import org.apache.zookeeper.Watcher;
|
|||
import org.apache.zookeeper.ZooKeeper;
|
||||
import org.apache.zookeeper.data.ACL;
|
||||
import org.apache.zookeeper.data.Stat;
|
||||
import org.skywalking.apm.collector.core.client.Client;
|
||||
import org.skywalking.apm.collector.core.component.client.Client;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.skywalking.apm.collector.client.zookeeper;
|
||||
|
||||
import org.skywalking.apm.collector.core.client.ClientException;
|
||||
import org.skywalking.apm.collector.core.component.client.ClientException;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
|
|||
|
|
@ -12,4 +12,25 @@
|
|||
<artifactId>server-component</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<jetty.version>9.4.2.v20170220</jetty.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>apm-network</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -21,9 +21,9 @@ package org.skywalking.apm.collector.server.grpc;
|
|||
import io.grpc.netty.NettyServerBuilder;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import org.skywalking.apm.collector.core.framework.Handler;
|
||||
import org.skywalking.apm.collector.core.server.Server;
|
||||
import org.skywalking.apm.collector.core.server.ServerException;
|
||||
import org.skywalking.apm.collector.core.component.server.Server;
|
||||
import org.skywalking.apm.collector.core.component.server.ServerException;
|
||||
import org.skywalking.apm.collector.core.component.server.ServerHandler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ public class GRPCServer implements Server {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void addHandler(Handler handler) {
|
||||
@Override public void addHandler(ServerHandler handler) {
|
||||
nettyServerBuilder.addService((io.grpc.BindableService)handler);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.skywalking.apm.collector.server.grpc;
|
||||
|
||||
import org.skywalking.apm.collector.core.server.ServerException;
|
||||
import org.skywalking.apm.collector.core.component.server.ServerException;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
|
|||
|
|
@ -12,4 +12,16 @@
|
|||
<artifactId>apm-collector-core</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>1.18</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.client;
|
||||
package org.skywalking.apm.collector.core.component.client;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.client;
|
||||
package org.skywalking.apm.collector.core.component.client;
|
||||
|
||||
import org.skywalking.apm.collector.core.CollectorException;
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.component.server;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface Server {
|
||||
|
||||
String hostPort();
|
||||
|
||||
String serverClassify();
|
||||
|
||||
void initialize() throws ServerException;
|
||||
|
||||
void start() throws ServerException;
|
||||
|
||||
void addHandler(ServerHandler handler);
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.component.server;
|
||||
|
||||
import org.skywalking.apm.collector.core.CollectorException;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public abstract class ServerException extends CollectorException {
|
||||
|
||||
public ServerException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ServerException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.component.server;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface ServerHandler {
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.component.server;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.collector.core.util.CollectionUtils;
|
||||
import org.skywalking.apm.collector.core.util.ObjectUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServerHolder {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(ServerHolder.class);
|
||||
|
||||
private List<Server> servers;
|
||||
|
||||
public ServerHolder() {
|
||||
servers = new LinkedList<>();
|
||||
}
|
||||
|
||||
public void holdServer(Server newServer, List<ServerHandler> handlers) throws ServerException {
|
||||
if (ObjectUtils.isEmpty(newServer) || CollectionUtils.isEmpty(handlers)) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isNewServer = true;
|
||||
for (Server server : servers) {
|
||||
if (server.hostPort().equals(newServer.hostPort()) && server.serverClassify().equals(newServer.serverClassify())) {
|
||||
isNewServer = false;
|
||||
addHandler(handlers, server);
|
||||
}
|
||||
}
|
||||
if (isNewServer) {
|
||||
newServer.initialize();
|
||||
servers.add(newServer);
|
||||
addHandler(handlers, newServer);
|
||||
}
|
||||
}
|
||||
|
||||
private void addHandler(List<ServerHandler> handlers, Server server) {
|
||||
if (CollectionUtils.isNotEmpty(handlers)) {
|
||||
handlers.forEach(handler -> {
|
||||
server.addHandler(handler);
|
||||
logger.debug("add handler into server: {}, handler name: {}", server.hostPort(), handler.getClass().getName());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public List<Server> getServers() {
|
||||
return servers;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.component.server;
|
||||
|
||||
import org.skywalking.apm.collector.core.module.ModuleDefine;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public abstract class ServerModuleDefine extends ModuleDefine {
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ public abstract class Module {
|
|||
/**
|
||||
* @return the {@link Service} provided by this module.
|
||||
*/
|
||||
public abstract Class<? extends Service>[] services();
|
||||
public abstract Class[] services();
|
||||
|
||||
/**
|
||||
* Run the prepare stage for the module, including finding all potential providers, and asking them to prepare.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.util;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class BytesUtils {
|
||||
|
||||
public static byte[] long2Bytes(long num) {
|
||||
byte[] byteNum = new byte[8];
|
||||
for (int ix = 0; ix < 8; ++ix) {
|
||||
int offset = 64 - (ix + 1) * 8;
|
||||
byteNum[ix] = (byte)((num >> offset) & 0xff);
|
||||
}
|
||||
return byteNum;
|
||||
}
|
||||
|
||||
public static long bytes2Long(byte[] byteNum) {
|
||||
long num = 0;
|
||||
for (int ix = 0; ix < 8; ++ix) {
|
||||
num <<= 8;
|
||||
num |= byteNum[ix] & 0xff;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class CollectionUtils {
|
||||
|
||||
public static boolean isEmpty(Map map) {
|
||||
return map == null || map.size() == 0;
|
||||
}
|
||||
|
||||
public static boolean isEmpty(List list) {
|
||||
return list == null || list.size() == 0;
|
||||
}
|
||||
|
||||
public static boolean isNotEmpty(List list) {
|
||||
return !isEmpty(list);
|
||||
}
|
||||
|
||||
public static boolean isNotEmpty(Map map) {
|
||||
return !isEmpty(map);
|
||||
}
|
||||
|
||||
public static <T> boolean isNotEmpty(T[] array) {
|
||||
return array != null && array.length > 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.util;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public enum ColumnNameUtils {
|
||||
INSTANCE;
|
||||
|
||||
public String rename(String columnName) {
|
||||
StringBuilder renamedColumnName = new StringBuilder();
|
||||
char[] chars = columnName.toLowerCase().toCharArray();
|
||||
|
||||
boolean findUnderline = false;
|
||||
for (char character : chars) {
|
||||
if (character == '_') {
|
||||
findUnderline = true;
|
||||
} else if (findUnderline) {
|
||||
renamedColumnName.append(String.valueOf(character).toUpperCase());
|
||||
findUnderline = false;
|
||||
} else {
|
||||
renamedColumnName.append(character);
|
||||
}
|
||||
}
|
||||
return renamedColumnName.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.util;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class Const {
|
||||
public static final String ID_SPLIT = "_";
|
||||
public static final int USER_ID = 1;
|
||||
public static final int NONE_SERVICE_ID = 1;
|
||||
public static final String NONE_SERVICE_NAME = "None";
|
||||
public static final String USER_CODE = "User";
|
||||
public static final String SEGMENT_SPAN_SPLIT = "S";
|
||||
public static final String UNKNOWN = "Unknown";
|
||||
public static final String EXCEPTION = "Exception";
|
||||
public static final String EMPTY_STRING = "";
|
||||
public static final String FILE_SUFFIX = "sw";
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import org.skywalking.apm.collector.core.framework.DefinitionFile;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class DefinitionLoader<D> implements Iterable<D> {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(DefinitionLoader.class);
|
||||
|
||||
private final Class<D> definition;
|
||||
private final DefinitionFile definitionFile;
|
||||
|
||||
protected DefinitionLoader(Class<D> svc, DefinitionFile definitionFile) {
|
||||
this.definition = Objects.requireNonNull(svc, "definition interface cannot be null");
|
||||
this.definitionFile = definitionFile;
|
||||
}
|
||||
|
||||
public static <D> DefinitionLoader<D> load(Class<D> definition, DefinitionFile definitionFile) {
|
||||
return new DefinitionLoader(definition, definitionFile);
|
||||
}
|
||||
|
||||
@Override public final Iterator<D> iterator() {
|
||||
logger.info("load definition file: {}", definitionFile.get());
|
||||
List<String> definitionList = new LinkedList<>();
|
||||
try {
|
||||
Enumeration<URL> urlEnumeration = this.getClass().getClassLoader().getResources(definitionFile.get());
|
||||
while (urlEnumeration.hasMoreElements()) {
|
||||
URL definitionFileURL = urlEnumeration.nextElement();
|
||||
logger.info("definition file url: {}", definitionFileURL.getPath());
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(definitionFileURL.openStream()));
|
||||
Properties properties = new Properties();
|
||||
properties.load(bufferedReader);
|
||||
|
||||
Enumeration defineItem = properties.propertyNames();
|
||||
while (defineItem.hasMoreElements()) {
|
||||
String fullNameClass = (String)defineItem.nextElement();
|
||||
definitionList.add(fullNameClass);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
Iterator<String> moduleDefineIterator = definitionList.iterator();
|
||||
|
||||
return new Iterator<D>() {
|
||||
@Override public boolean hasNext() {
|
||||
return moduleDefineIterator.hasNext();
|
||||
}
|
||||
|
||||
@Override public D next() {
|
||||
String definitionClass = moduleDefineIterator.next();
|
||||
logger.info("definitionClass: {}", definitionClass);
|
||||
try {
|
||||
Class c = Class.forName(definitionClass);
|
||||
return (D)c.newInstance();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.util;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ObjectUtils {
|
||||
public static boolean isEmpty(Object obj) {
|
||||
return obj == null;
|
||||
}
|
||||
|
||||
public static boolean isNotEmpty(Object obj) {
|
||||
return !isEmpty(obj);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.util;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ResourceUtils {
|
||||
|
||||
public static Reader read(String fileName) throws FileNotFoundException {
|
||||
URL url = ResourceUtils.class.getClassLoader().getResource(fileName);
|
||||
if (url == null) {
|
||||
throw new FileNotFoundException("file not found: " + fileName);
|
||||
}
|
||||
InputStream inputStream = ResourceUtils.class.getClassLoader().getResourceAsStream(fileName);
|
||||
return new InputStreamReader(inputStream);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.util;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class StringUtils {
|
||||
|
||||
public static final String EMPTY_STRING = "";
|
||||
|
||||
public static boolean isEmpty(Object str) {
|
||||
return str == null || EMPTY_STRING.equals(str);
|
||||
}
|
||||
|
||||
public static boolean isNotEmpty(Object str) {
|
||||
return !isEmpty(str);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.core.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
import org.skywalking.apm.collector.core.framework.UnexpectedException;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public enum TimeBucketUtils {
|
||||
INSTANCE;
|
||||
|
||||
private final SimpleDateFormat dayDateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
private final SimpleDateFormat hourDateFormat = new SimpleDateFormat("yyyyMMddHH");
|
||||
private final SimpleDateFormat minuteDateFormat = new SimpleDateFormat("yyyyMMddHHmm");
|
||||
private final SimpleDateFormat secondDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
|
||||
public long getMinuteTimeBucket(long time) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(time);
|
||||
String timeStr = minuteDateFormat.format(calendar.getTime());
|
||||
return Long.valueOf(timeStr);
|
||||
}
|
||||
|
||||
public long getSecondTimeBucket(long time) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(time);
|
||||
String timeStr = secondDateFormat.format(calendar.getTime());
|
||||
return Long.valueOf(timeStr);
|
||||
}
|
||||
|
||||
public long getHourTimeBucket(long time) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(time);
|
||||
String timeStr = hourDateFormat.format(calendar.getTime()) + "00";
|
||||
return Long.valueOf(timeStr);
|
||||
}
|
||||
|
||||
public long getDayTimeBucket(long time) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(time);
|
||||
String timeStr = dayDateFormat.format(calendar.getTime()) + "0000";
|
||||
return Long.valueOf(timeStr);
|
||||
}
|
||||
|
||||
public long changeTimeBucket2TimeStamp(String timeBucketType, long timeBucket) {
|
||||
if (TimeBucketType.SECOND.name().toLowerCase().equals(timeBucketType.toLowerCase())) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.YEAR, Integer.valueOf(String.valueOf(timeBucket).substring(0, 4)));
|
||||
calendar.set(Calendar.MONTH, Integer.valueOf(String.valueOf(timeBucket).substring(4, 6)) - 1);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, Integer.valueOf(String.valueOf(timeBucket).substring(6, 8)));
|
||||
calendar.set(Calendar.HOUR_OF_DAY, Integer.valueOf(String.valueOf(timeBucket).substring(8, 10)));
|
||||
calendar.set(Calendar.MINUTE, Integer.valueOf(String.valueOf(timeBucket).substring(10, 12)));
|
||||
calendar.set(Calendar.SECOND, Integer.valueOf(String.valueOf(timeBucket).substring(12, 14)));
|
||||
return calendar.getTimeInMillis();
|
||||
} else if (TimeBucketType.MINUTE.name().toLowerCase().equals(timeBucketType.toLowerCase())) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.YEAR, Integer.valueOf(String.valueOf(timeBucket).substring(0, 4)));
|
||||
calendar.set(Calendar.MONTH, Integer.valueOf(String.valueOf(timeBucket).substring(4, 6)) - 1);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, Integer.valueOf(String.valueOf(timeBucket).substring(6, 8)));
|
||||
calendar.set(Calendar.HOUR_OF_DAY, Integer.valueOf(String.valueOf(timeBucket).substring(8, 10)));
|
||||
calendar.set(Calendar.MINUTE, Integer.valueOf(String.valueOf(timeBucket).substring(10, 12)));
|
||||
return calendar.getTimeInMillis();
|
||||
} else {
|
||||
throw new UnexpectedException("time bucket type must be second or minute");
|
||||
}
|
||||
}
|
||||
|
||||
public long[] getFiveSecondTimeBuckets(long secondTimeBucket) {
|
||||
long timeStamp = changeTimeBucket2TimeStamp(TimeBucketType.SECOND.name(), secondTimeBucket);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(timeStamp);
|
||||
|
||||
long[] timeBuckets = new long[5];
|
||||
timeBuckets[0] = secondTimeBucket;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
calendar.add(Calendar.SECOND, -1);
|
||||
timeBuckets[i + 1] = getSecondTimeBucket(calendar.getTimeInMillis());
|
||||
}
|
||||
return timeBuckets;
|
||||
}
|
||||
|
||||
public long changeToUTCTimeBucket(long timeBucket) {
|
||||
String timeBucketStr = String.valueOf(timeBucket);
|
||||
|
||||
if (TimeZone.getDefault().getID().equals("GMT+08:00") || timeBucketStr.endsWith("0000")) {
|
||||
return timeBucket;
|
||||
} else {
|
||||
return timeBucket - 800;
|
||||
}
|
||||
}
|
||||
|
||||
public long addSecondForSecondTimeBucket(String timeBucketType, long timeBucket, int second) {
|
||||
if (!TimeBucketType.SECOND.name().equals(timeBucketType)) {
|
||||
throw new UnexpectedException("time bucket type must be second ");
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(changeTimeBucket2TimeStamp(timeBucketType, timeBucket));
|
||||
calendar.add(Calendar.SECOND, second);
|
||||
|
||||
return getSecondTimeBucket(calendar.getTimeInMillis());
|
||||
}
|
||||
|
||||
public enum TimeBucketType {
|
||||
SECOND, MINUTE, HOUR, DAY
|
||||
}
|
||||
}
|
||||
|
|
@ -41,5 +41,10 @@
|
|||
<artifactId>collector-cluster-define</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>server-component</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.naming.jetty.handler;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.skywalking.apm.collector.server.jetty.ArgumentsParseException;
|
||||
import org.skywalking.apm.collector.server.jetty.JettyHandler;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class AgentGRPCNamingHandler extends JettyHandler {
|
||||
|
||||
@Override public String pathSpec() {
|
||||
return "/agentstream/grpc";
|
||||
}
|
||||
|
||||
@Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException {
|
||||
// ModuleManager
|
||||
// ClusterModuleRegistrationReader reader = CollectorContextHelper.INSTANCE.getClusterModuleContext().getReader();
|
||||
// Set<String> servers = reader.read(AgentStreamGRPCDataListener.PATH);
|
||||
JsonArray serverArray = new JsonArray();
|
||||
// servers.forEach(serverArray::add);
|
||||
return serverArray;
|
||||
}
|
||||
|
||||
@Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.naming.jetty.handler;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.skywalking.apm.collector.server.jetty.ArgumentsParseException;
|
||||
import org.skywalking.apm.collector.server.jetty.JettyHandler;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class AgentJettyNamingHandler extends JettyHandler {
|
||||
|
||||
@Override public String pathSpec() {
|
||||
return "/agentstream/jetty";
|
||||
}
|
||||
|
||||
@Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException {
|
||||
// ClusterModuleRegistrationReader reader = CollectorContextHelper.INSTANCE.getClusterModuleContext().getReader();
|
||||
// Set<String> servers = reader.read(AgentStreamJettyDataListener.PATH);
|
||||
JsonArray serverArray = new JsonArray();
|
||||
// servers.forEach(serverArray::add);
|
||||
return serverArray;
|
||||
}
|
||||
|
||||
@Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.naming.jetty.handler;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.skywalking.apm.collector.server.jetty.ArgumentsParseException;
|
||||
import org.skywalking.apm.collector.server.jetty.JettyHandler;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class UIJettyNamingHandler extends JettyHandler {
|
||||
|
||||
@Override public String pathSpec() {
|
||||
return "/ui/jetty";
|
||||
}
|
||||
|
||||
@Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException {
|
||||
// ClusterModuleRegistrationReader reader = CollectorContextHelper.INSTANCE.getClusterModuleContext().getReader();
|
||||
// Set<String> servers = reader.read(UIJettyDataListener.PATH);
|
||||
JsonArray serverArray = new JsonArray();
|
||||
// servers.forEach(serverArray::add);
|
||||
return serverArray;
|
||||
}
|
||||
|
||||
@Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue