use of javax.annotation.PostConstruct in project pinpoint by naver.
the class TCPReceiver method start.
@PostConstruct
public void start() {
afterPropertiesSet();
// take care when attaching message handlers as events are generated from the IO thread.
// pass them to a separate queue and handle them in a different thread.
this.serverAcceptor.setMessageListener(new ServerMessageListener() {
@Override
public HandshakeResponseCode handleHandshake(Map properties) {
if (properties == null) {
return HandshakeResponseType.ProtocolError.PROTOCOL_ERROR;
}
boolean hasRequiredKeys = HandshakePropertyType.hasRequiredKeys(properties);
if (!hasRequiredKeys) {
return HandshakeResponseType.PropertyError.PROPERTY_ERROR;
}
boolean supportServer = MapUtils.getBoolean(properties, HandshakePropertyType.SUPPORT_SERVER.getName(), true);
if (supportServer) {
return HandshakeResponseType.Success.DUPLEX_COMMUNICATION;
} else {
return HandshakeResponseType.Success.SIMPLEX_COMMUNICATION;
}
}
@Override
public void handleSend(SendPacket sendPacket, PinpointSocket pinpointSocket) {
receive(sendPacket, pinpointSocket);
}
@Override
public void handleRequest(RequestPacket requestPacket, PinpointSocket pinpointSocket) {
requestResponse(requestPacket, pinpointSocket);
}
@Override
public void handlePing(PingPacket pingPacket, PinpointServer pinpointServer) {
recordPing(pingPacket, pinpointServer);
}
});
this.serverAcceptor.bind(configuration.getTcpListenIp(), configuration.getTcpListenPort());
}
use of javax.annotation.PostConstruct in project pinpoint by naver.
the class TestUDPReceiver method start.
@PostConstruct
@Override
public void start() {
logger.info("{} start.", receiverName);
afterPropertiesSet();
final DatagramSocket socket = this.socket;
if (socket == null) {
throw new IllegalStateException("socket is null.");
}
bindSocket(socket, bindAddress, port);
logger.info("UDP Packet reader:{} started.", ioThreadSize);
for (int i = 0; i < ioThreadSize; i++) {
io.execute(new Runnable() {
@Override
public void run() {
receive(socket);
}
});
}
}
use of javax.annotation.PostConstruct in project pinpoint by naver.
the class ApisController method initApiMappings.
@PostConstruct
private void initApiMappings() {
Map<RequestMappingInfo, HandlerMethod> requestMappedHandlers = this.handlerMapping.getHandlerMethods();
for (Map.Entry<RequestMappingInfo, HandlerMethod> requestMappedHandlerEntry : requestMappedHandlers.entrySet()) {
RequestMappingInfo requestMappingInfo = requestMappedHandlerEntry.getKey();
HandlerMethod handlerMethod = requestMappedHandlerEntry.getValue();
Class<?> handlerMethodBeanClazz = handlerMethod.getBeanType();
if (handlerMethodBeanClazz == this.getClass()) {
continue;
}
String controllerName = handlerMethodBeanClazz.getSimpleName();
Set<String> mappedRequests = requestMappingInfo.getPatternsCondition().getPatterns();
SortedSet<RequestMappedUri> alreadyMappedRequests = this.apiMappings.get(controllerName);
if (alreadyMappedRequests == null) {
alreadyMappedRequests = new TreeSet<RequestMappedUri>(RequestMappedUri.MAPPED_URI_ORDER);
this.apiMappings.put(controllerName, alreadyMappedRequests);
}
alreadyMappedRequests.addAll(createRequestMappedApis(handlerMethod, mappedRequests));
}
}
use of javax.annotation.PostConstruct in project pinpoint by naver.
the class ZookeeperClusterService method setUp.
@PostConstruct
@Override
public void setUp() throws KeeperException, IOException, InterruptedException {
if (!config.isClusterEnable()) {
logger.info("pinpoint-collector cluster disable.");
return;
}
switch(this.serviceState.getCurrentState()) {
case NEW:
if (this.serviceState.changeStateInitializing()) {
logger.info("{} initialization started.", this.getClass().getSimpleName());
ClusterManagerWatcher watcher = new ClusterManagerWatcher();
this.client = new DefaultZookeeperClient(config.getClusterAddress(), config.getClusterSessionTimeout(), watcher);
this.client.connect();
this.profilerClusterManager = new ZookeeperProfilerClusterManager(client, serverIdentifier, clusterPointRouter.getTargetClusterPointRepository());
this.profilerClusterManager.start();
this.webClusterManager = new ZookeeperWebClusterManager(client, PINPOINT_WEB_CLUSTER_PATH, serverIdentifier, clusterConnectionManager);
this.webClusterManager.start();
this.serviceState.changeStateStarted();
logger.info("{} initialization completed.", this.getClass().getSimpleName());
if (client.isConnected()) {
WatcherEvent watcherEvent = new WatcherEvent(EventType.None.getIntValue(), KeeperState.SyncConnected.getIntValue(), "");
WatchedEvent event = new WatchedEvent(watcherEvent);
watcher.process(event);
}
}
break;
case INITIALIZING:
logger.info("{} already initializing.", this.getClass().getSimpleName());
break;
case STARTED:
logger.info("{} already started.", this.getClass().getSimpleName());
break;
case DESTROYING:
throw new IllegalStateException("Already destroying.");
case STOPPED:
throw new IllegalStateException("Already stopped.");
case ILLEGAL_STATE:
throw new IllegalStateException("Invalid State.");
}
}
use of javax.annotation.PostConstruct in project pinpoint by naver.
the class ClusterManager method start.
@PostConstruct
public void start() throws InterruptedException, IOException, KeeperException {
logger.info("start() started.");
if (!config.isClusterEnable()) {
logger.info("start() skipped. caused:cluster option disabled.");
return;
}
try {
clusterConnectionManager.start();
clusterDataManager.start();
ClusterAcceptor clusterAcceptor = clusterConnectionManager.getClusterAcceptor();
if (clusterAcceptor != null) {
String nodeName = clusterAcceptor.getBindHost() + ":" + clusterAcceptor.getBindPort();
List<String> localIpList = NetUtils.getLocalV4IpList();
clusterDataManager.registerWebCluster(nodeName, convertIpListToBytes(localIpList, "\r\n"));
}
} catch (Exception e) {
logger.warn("start() failed. caused:{}.", e.getMessage(), e);
clearResource();
}
logger.info("start() completed.");
}
Aggregations