metron-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cestella <...@git.apache.org>
Subject [GitHub] incubator-metron pull request #228: METRON-390: Stellar functions should ini...
Date Wed, 24 Aug 2016 17:10:36 GMT
Github user cestella commented on a diff in the pull request:

    https://github.com/apache/incubator-metron/pull/228#discussion_r76098304
  
    --- Diff: metron-platform/metron-common/src/main/java/org/apache/metron/common/dsl/functions/MaaSFunctions.java
---
    @@ -234,25 +248,36 @@ public Object apply(List<Object> args, Context context) throws
ParseException {
           }
           return ret;
         }
    +
         @Override
    -    public void initialize(Context context) {
    -      Optional<Object> clientOptional = context.getCapability(Context.Capabilities.ZOOKEEPER_CLIENT);
    -      CuratorFramework client = null;
    -      if(clientOptional.isPresent() && clientOptional.get() instanceof CuratorFramework)
{
    -        client = (CuratorFramework)clientOptional.get();
    -      }
    -      else {
    -        return;
    -      }
    +    public synchronized void initialize(Context context) {
           try {
    -        MaaSConfig config = ConfigUtil.INSTANCE.read(client, "/metron/maas/config", new
MaaSConfig(), MaaSConfig.class);
    -        discoverer = new ServiceDiscoverer(client, config.getServiceRoot());
    -        discoverer.start();
    -        context.addCapability(Context.Capabilities.SERVICE_DISCOVERER, () -> discoverer);
    -      } catch (Exception e) {
    -        LOG.error(e.getMessage(), e);
    -        return;
    +        Optional<Object> clientOptional = context.getCapability(Context.Capabilities.ZOOKEEPER_CLIENT);
    +        CuratorFramework client = null;
    +        if (clientOptional.isPresent() && clientOptional.get() instanceof CuratorFramework)
{
    +          client = (CuratorFramework) clientOptional.get();
    +        } else {
    +          return;
    +        }
    +        try {
    +          MaaSConfig config = ConfigUtil.INSTANCE.read(client, "/metron/maas/config",
new MaaSConfig(), MaaSConfig.class);
    +          discoverer = new ServiceDiscoverer(client, config.getServiceRoot());
    +          discoverer.start();
    +          context.addCapability(Context.Capabilities.SERVICE_DISCOVERER, () -> discoverer);
    +          isValidState = true;
    +        } catch (Exception e) {
    +          LOG.error(e.getMessage(), e);
    --- End diff --
    
    Yeah, agreed.  Throwing an exception here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message