Search in sources :

Example 1 with AbstractSystemInvoker

use of com.creditease.agent.spi.AbstractSystemInvoker in project uavstack by uavorg.

the class PushNotifyEventAction method run.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public boolean run(NotificationEvent event) {
    AbstractSystemInvoker invoker = this.getSystemInvokerMgr().getSystemInvoker(InvokerType.HTTP);
    UAVHttpMessage tmsg = new UAVHttpMessage();
    tmsg.setIntent("ntfpush");
    tmsg.putRequest("ntfevent", event.toJSONString());
    String serviceStr = this.getConfigManager().getFeatureConfiguration(this.feature, "push.services");
    if (StringHelper.isEmpty(serviceStr)) {
        return true;
    }
    String[] services = serviceStr.split(",");
    boolean check = true;
    for (String service : services) {
        try {
            Map<String, Object> res = (Map<String, Object>) invoker.invoke(service, tmsg, Map.class);
            if (res == null) {
                check = false;
                continue;
            }
            if (log.isTraceEnable()) {
                log.info(this, "Push Notification to Service[" + service + "] SUCCESS.");
            }
            return true;
        } catch (Exception e) {
            check = false;
        // ignore
        }
    }
    return check;
}
Also used : UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) Map(java.util.Map) AbstractSystemInvoker(com.creditease.agent.spi.AbstractSystemInvoker)

Example 2 with AbstractSystemInvoker

use of com.creditease.agent.spi.AbstractSystemInvoker in project uavstack by uavorg.

the class LineNumberWriter method testSystemInvoker.

private void testSystemInvoker() {
    Thread thd = new Thread(new Runnable() {

        @Override
        public void run() {
            ThreadHelper.suspend(5000);
            // AgentFeatureComponent afc = (AgentFeatureComponent) getConfigManager().getComponent("hbclientagent",
            // "HeartBeatClientAgent");
            // 
            // if (afc == null) {
            // return;
            // }
            // 
            // String[] urls = (String[]) afc.exchange("hbclientagent.service.discovery",
            // "healthmanager-HealthMangerServerWorker-/hm/cache/q");
            // 
            // log.info(this, ">>" + urls);
            AbstractSystemInvoker invoker = getSystemInvokerMgr().getSystemInvoker(InvokerType.HTTP);
            for (int i = 0; i < 5; i++) {
                UAVHttpMessage msg = new UAVHttpMessage();
                msg.setIntent("services");
                msg.putRequest("service", "hbserveragent-HeartBeatQueryListenWorker-/hb/query");
                String res = (String) invoker.invoke("hbserveragent-HeartBeatQueryListenWorker-/hb/query", msg, String.class);
                log.info(this, ">>" + res);
            // invoker.invoke("hbserveragent-HeartBeatQueryListenWorker-/hb/query", msg, new
            // HttpClientCallback() {
            // 
            // @Override
            // public void completed(HttpClientCallbackResult result) {
            // 
            // log.info(this, ">>" + result.getReplyDataAsString());
            // }
            // 
            // @Override
            // public void failed(HttpClientCallbackResult result) {
            // 
            // }
            // 
            // });
            }
            log.info(this, ">>>>");
        }
    });
    thd.start();
}
Also used : UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) AbstractSystemInvoker(com.creditease.agent.spi.AbstractSystemInvoker)

Example 3 with AbstractSystemInvoker

use of com.creditease.agent.spi.AbstractSystemInvoker in project uavstack by uavorg.

the class SystemInvokerManager method shutdown.

@SuppressWarnings("rawtypes")
@Override
public void shutdown() {
    Set<AbstractSystemInvoker> abs = ConfigurationManager.getInstance().getComponents(AbstractSystemInvoker.class);
    for (AbstractSystemInvoker invoker : abs) {
        invoker.stop();
        ConfigurationManager.getInstance().unregisterComponent(invoker.getFeature(), invoker.getName());
    }
}
Also used : AbstractSystemInvoker(com.creditease.agent.spi.AbstractSystemInvoker)

Aggregations

AbstractSystemInvoker (com.creditease.agent.spi.AbstractSystemInvoker)3 UAVHttpMessage (com.creditease.agent.http.api.UAVHttpMessage)2 Map (java.util.Map)1