Codota Logo
EventManager
Code IndexAdd Codota to your IDE (free)

How to use
EventManager
in
org.apache.servicecomb.foundation.common.event

Best Java code snippets using org.apache.servicecomb.foundation.common.event.EventManager (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: apache/servicecomb-java-chassis

@Override
public void onBusinessMethodFinish() {
 EventManager.post(new InvocationBusinessMethodFinishEvent(this));
}
origin: apache/servicecomb-java-chassis

public MemberDiscovery(List<String> configCenterUri) {
 if (configCenterUri != null && !configCenterUri.isEmpty()) {
  configServerAddresses.addAll(configCenterUri);
 }
 Collections.shuffle(configServerAddresses);
 EventManager.register(this);
}
origin: apache/servicecomb-java-chassis

 @Subscribe
 public void afterRegistryInstance(MicroserviceInstanceRegisterTask microserviceInstanceRegisterTask) {
  LOGGER.info("receive MicroserviceInstanceRegisterTask event, check instance Id...");
  if (!StringUtils.isEmpty(RegistryUtils.getMicroserviceInstance().getInstanceId())) {
   LOGGER.info("instance registry succeeds for the first time, will send AFTER_REGISTRY event.");
   status = SCBStatus.UP;
   triggerEvent(EventType.AFTER_REGISTRY);
   EventManager.unregister(this);
   LOGGER.info("ServiceComb is ready.");
  }
 }
});
origin: apache/servicecomb-java-chassis

@Override
public void onBootEvent(BootEvent event) {
 switch (event.getEventType()) {
  case BEFORE_PRODUCER_PROVIDER:
   registerSchemas();
   break;
  case AFTER_REGISTRY:
   metricsBootstrap.start(new GlobalRegistry(), EventManager.getEventBus());
   break;
  case BEFORE_CLOSE:
   metricsBootstrap.shutdown();
   break;
  default:
   break;
 }
}
origin: org.apache.servicecomb/metrics-core

@Override
public void onBootEvent(BootEvent event) {
 switch (event.getEventType()) {
  case BEFORE_PRODUCER_PROVIDER:
   registerSchemas();
   break;
  case AFTER_REGISTRY:
   metricsBootstrap.start(new GlobalRegistry(), EventManager.getEventBus());
   break;
  case BEFORE_CLOSE:
   metricsBootstrap.shutdown();
   break;
  default:
   break;
 }
}
origin: apache/servicecomb-java-chassis

private void sendHeartbeat(WebSocket ws) {
 try {
  ws.writeFrame(new WebSocketFrameImpl(FrameType.PING));
  EventManager.post(new ConnSuccEvent());
 } catch (IllegalStateException e) {
  EventManager.post(new ConnFailEvent("heartbeat fail, " + e.getMessage()));
  LOGGER.error("heartbeat fail", e);
 }
}
origin: apache/servicecomb-java-chassis

/**
 * <p>As the process of instance registry is asynchronous, the {@code AFTER_REGISTRY}
 * event should not be sent immediately after {@link RegistryUtils#run()} is invoked.
 * When the instance registry succeeds, {@link MicroserviceInstanceRegisterTask} will be posted in {@link EventManager},
 * register a subscriber to watch this event and send {@code AFTER_REGISTRY}.</p>
 *
 * <p>This method should be called before {@link RegistryUtils#run()} to avoid that the registry process is too quick
 * that the event is not watched by this subscriber.</p>
 *
 * <p>Check if {@code InstanceId} is null to judge whether the instance registry has succeeded.</p>
 */
private void triggerAfterRegistryEvent() {
 EventManager.register(new Object() {
  @Subscribe
  public void afterRegistryInstance(MicroserviceInstanceRegisterTask microserviceInstanceRegisterTask) {
   LOGGER.info("receive MicroserviceInstanceRegisterTask event, check instance Id...");
   if (!StringUtils.isEmpty(RegistryUtils.getMicroserviceInstance().getInstanceId())) {
    LOGGER.info("instance registry succeeds for the first time, will send AFTER_REGISTRY event.");
    status = SCBStatus.UP;
    triggerEvent(EventType.AFTER_REGISTRY);
    EventManager.unregister(this);
    LOGGER.info("ServiceComb is ready.");
   }
  }
 });
}
origin: org.apache.servicecomb/java-chassis-core

 @Subscribe
 public void afterRegistryInstance(MicroserviceInstanceRegisterTask microserviceInstanceRegisterTask) {
  LOGGER.info("receive MicroserviceInstanceRegisterTask event, check instance Id...");
  if (!StringUtils.isEmpty(RegistryUtils.getMicroserviceInstance().getInstanceId())) {
   LOGGER.info("instance registry succeeds for the first time, will send AFTER_REGISTRY event.");
   status = SCBStatus.UP;
   triggerEvent(EventType.AFTER_REGISTRY);
   EventManager.unregister(this);
   LOGGER.info("ServiceComb is ready.");
  }
 }
});
origin: apache/servicecomb-java-chassis

@Override
public void onBusinessMethodStart() {
 invocationStageTrace.startBusinessMethod();
 EventManager.post(new InvocationBusinessMethodStartEvent(this));
}
origin: org.apache.servicecomb/config-cc

public MemberDiscovery(List<String> configCenterUri) {
 if (configCenterUri != null && !configCenterUri.isEmpty()) {
  configServerAddresses.addAll(configCenterUri);
 }
 Collections.shuffle(configServerAddresses);
 EventManager.register(this);
}
origin: apache/servicecomb-java-chassis

public void onFinish(Response response) {
 if (finished) {
  // avoid to post repeated event
  return;
 }
 invocationStageTrace.finish();
 EventManager.post(new InvocationFinishEvent(this, response));
 finished = true;
}
origin: org.apache.servicecomb/java-chassis-core

/**
 * <p>As the process of instance registry is asynchronous, the {@code AFTER_REGISTRY}
 * event should not be sent immediately after {@link RegistryUtils#run()} is invoked.
 * When the instance registry succeeds, {@link MicroserviceInstanceRegisterTask} will be posted in {@link EventManager},
 * register a subscriber to watch this event and send {@code AFTER_REGISTRY}.</p>
 *
 * <p>This method should be called before {@link RegistryUtils#run()} to avoid that the registry process is too quick
 * that the event is not watched by this subscriber.</p>
 *
 * <p>Check if {@code InstanceId} is null to judge whether the instance registry has succeeded.</p>
 */
private void triggerAfterRegistryEvent() {
 EventManager.register(new Object() {
  @Subscribe
  public void afterRegistryInstance(MicroserviceInstanceRegisterTask microserviceInstanceRegisterTask) {
   LOGGER.info("receive MicroserviceInstanceRegisterTask event, check instance Id...");
   if (!StringUtils.isEmpty(RegistryUtils.getMicroserviceInstance().getInstanceId())) {
    LOGGER.info("instance registry succeeds for the first time, will send AFTER_REGISTRY event.");
    status = SCBStatus.UP;
    triggerEvent(EventType.AFTER_REGISTRY);
    EventManager.unregister(this);
    LOGGER.info("ServiceComb is ready.");
   }
  }
 });
}
origin: apache/servicecomb-java-chassis

public void onStart(long start) {
 invocationStageTrace.start(start);
 initTraceId();
 EventManager.post(new InvocationStartEvent(this));
}
origin: apache/servicecomb-java-chassis

 private HeartbeatResult heartbeat() {
  HeartbeatResponse response =
    srClient.heartbeat(microserviceInstance.getServiceId(), microserviceInstance.getInstanceId());
  if (response == null) {
   LOGGER.error("Disconnected from service center and heartbeat failed for microservice instance={}/{}",
     microserviceInstance.getServiceId(),
     microserviceInstance.getInstanceId());
   EventManager.post(new HeartbeatFailEvent());
   return HeartbeatResult.DISCONNECTED;
  }

  if (!response.isOk()) {
   LOGGER.error("Update heartbeat to service center failed, microservice instance={}/{} does not exist",
     microserviceInstance.getServiceId(),
     microserviceInstance.getInstanceId());
   EventManager.post(new HeartbeatFailEvent());
   return HeartbeatResult.INSTANCE_NOT_REGISTERED;
  }
  EventManager.post(new HeartbeatSuccEvent());
  return HeartbeatResult.SUCCESS;
 }
}
origin: apache/servicecomb-java-chassis

        new TypeReference<LinkedHashMap<String, Map<String, String>>>() {
        }));
    EventManager.post(new ConnSuccEvent());
   } catch (IOException e) {
    EventManager.post(new ConnFailEvent(
      "config update result parse fail " + e.getMessage()));
    LOGGER.error("Config update from {} failed. Error message is [{}].",
 } else if (rsp.statusCode() == HttpResponseStatus.NOT_MODIFIED.code()) {
  EventManager.post(new ConnSuccEvent());
  if (LOGGER.isDebugEnabled()) {
   LOGGER.debug("Updating remote config is done. the revision {} has no change",
   latch.countDown();
  });
  EventManager.post(new ConnFailEvent("fetch config fail"));
  LOGGER.error("Config update from {} failed.", configcenter);
    null))));
request.exceptionHandler(e -> {
 EventManager.post(new ConnFailEvent("fetch config fail"));
 LOGGER.error("Config update from {} failed. Error message is [{}].",
   configcenter,
origin: org.apache.servicecomb/java-chassis-core

@Override
public void onBusinessMethodFinish() {
 EventManager.post(new InvocationBusinessMethodFinishEvent(this));
}
origin: org.apache.servicecomb/config-cc

private void sendHeartbeat(WebSocket ws) {
 try {
  ws.writeFrame(new WebSocketFrameImpl(FrameType.PING));
  EventManager.post(new ConnSuccEvent());
 } catch (IllegalStateException e) {
  EventManager.post(new ConnFailEvent("heartbeat fail, " + e.getMessage()));
  LOGGER.error("heartbeat fail", e);
 }
}
origin: org.apache.servicecomb/java-chassis-core

@Override
public void onBusinessMethodStart() {
 invocationStageTrace.startBusinessMethod();
 EventManager.post(new InvocationBusinessMethodStartEvent(this));
}
origin: org.apache.servicecomb/java-chassis-core

public void onFinish(Response response) {
 if (finished) {
  // avoid to post repeated event
  return;
 }
 invocationStageTrace.finish();
 EventManager.post(new InvocationFinishEvent(this, response));
 finished = true;
}
origin: org.apache.servicecomb/java-chassis-core

public void onStart(long start) {
 invocationStageTrace.start(start);
 initTraceId();
 EventManager.post(new InvocationStartEvent(this));
}
org.apache.servicecomb.foundation.common.eventEventManager

Javadoc

EventManager for chassis events

Most used methods

  • post
    post event.
  • register
    Registering listener.
  • getEventBus
  • unregister
    Unregistering listener.

Popular in Java

  • Reading from database using SQL prepared statement
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • getSharedPreferences (Context)
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • JList (javax.swing)
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Logger (org.slf4j)
    The main user interface to logging. It is expected that logging takes place through concrete impleme
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now