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();
}
}
}
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.");
}
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());
}
Aggregations