Search in sources :

Example 26 with PostConstruct

use of javax.annotation.PostConstruct in project che by eclipse.

the class DockerRegistryChecker method checkRegistryIsAvailable.

/**
     * Checks that registry is available and if it is not - logs warning message.
     */
@PostConstruct
private void checkRegistryIsAvailable() throws IOException {
    if (snapshotUseRegistry && !isNullOrEmpty(machineDockerRegistry)) {
        String registryUrl = "http://" + machineDockerRegistry;
        LOG.info("Probing registry '{}'", registryUrl);
        final HttpURLConnection conn = (HttpURLConnection) new URL(registryUrl).openConnection();
        conn.setConnectTimeout(30 * 1000);
        try {
            final int responseCode = conn.getResponseCode();
            LOG.info("Probe of registry '{}' succeed with HTTP response code '{}'", registryUrl, responseCode);
        } catch (IOException ioEx) {
            LOG.warn("Docker registry {} is not available, " + "which means that you won't be able to save snapshots of your workspaces." + "\nHow to configure registry?" + "\n\tLocal registry  -> https://docs.docker.com/registry/" + "\n\tRemote registry -> set up 'che.docker.registry.auth.*' properties", registryUrl);
        } finally {
            conn.disconnect();
        }
    }
}
Also used : HttpURLConnection(java.net.HttpURLConnection) IOException(java.io.IOException) URL(java.net.URL) PostConstruct(javax.annotation.PostConstruct)

Example 27 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 28 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 29 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)

Example 30 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)

Aggregations

PostConstruct (javax.annotation.PostConstruct)248 IOException (java.io.IOException)28 File (java.io.File)18 SamlRegisteredService (org.apereo.cas.support.saml.services.SamlRegisteredService)17 Map (java.util.Map)15 ArrayList (java.util.ArrayList)12 ExternalResource (com.vaadin.server.ExternalResource)11 HashMap (java.util.HashMap)10 InitialContext (javax.naming.InitialContext)9 Label (com.vaadin.ui.Label)8 VerticalLayout (com.vaadin.ui.VerticalLayout)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)7 Method (java.lang.reflect.Method)5 InputStream (java.io.InputStream)4 URISyntaxException (java.net.URISyntaxException)4 Path (java.nio.file.Path)4