Search in sources :

Example 21 with PostConstruct

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());
}
Also used : RequestPacket(com.navercorp.pinpoint.rpc.packet.RequestPacket) ServerMessageListener(com.navercorp.pinpoint.rpc.server.ServerMessageListener) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) SendPacket(com.navercorp.pinpoint.rpc.packet.SendPacket) HandshakeResponseCode(com.navercorp.pinpoint.rpc.packet.HandshakeResponseCode) PinpointServer(com.navercorp.pinpoint.rpc.server.PinpointServer) PingPacket(com.navercorp.pinpoint.rpc.packet.PingPacket) Map(java.util.Map) PostConstruct(javax.annotation.PostConstruct)

Example 22 with PostConstruct

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);
            }
        });
    }
}
Also used : DatagramSocket(java.net.DatagramSocket) PostConstruct(javax.annotation.PostConstruct)

Example 23 with PostConstruct

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));
    }
}
Also used : RequestMappingInfo(org.springframework.web.servlet.mvc.method.RequestMappingInfo) TreeMap(java.util.TreeMap) Map(java.util.Map) HandlerMethod(org.springframework.web.method.HandlerMethod) PostConstruct(javax.annotation.PostConstruct)

Example 24 with PostConstruct

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.");
    }
}
Also used : WatchedEvent(org.apache.zookeeper.WatchedEvent) WatcherEvent(org.apache.zookeeper.proto.WatcherEvent) PostConstruct(javax.annotation.PostConstruct)

Example 25 with PostConstruct

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.");
}
Also used : KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) ClusterAcceptor(com.navercorp.pinpoint.web.cluster.connection.ClusterAcceptor) PostConstruct(javax.annotation.PostConstruct)

Aggregations

PostConstruct (javax.annotation.PostConstruct)194 IOException (java.io.IOException)24 File (java.io.File)16 SamlRegisteredService (org.apereo.cas.support.saml.services.SamlRegisteredService)16 Map (java.util.Map)13 ExternalResource (com.vaadin.server.ExternalResource)11 ArrayList (java.util.ArrayList)11 Label (com.vaadin.ui.Label)8 VerticalLayout (com.vaadin.ui.VerticalLayout)8 HashMap (java.util.HashMap)8 Request (com.nabalive.framework.web.Request)7 Response (com.nabalive.framework.web.Response)7 Route (com.nabalive.framework.web.Route)7 Link (com.vaadin.ui.Link)7 Properties (java.util.Properties)6 InitialContext (javax.naming.InitialContext)6 IStatus (org.eclipse.core.runtime.IStatus)5 URISyntaxException (java.net.URISyntaxException)4 Logger (org.slf4j.Logger)4 StatusLineWriter (alma.acs.eventbrowser.status.StatusLineWriter)3