fluo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikewalch <...@git.apache.org>
Subject [GitHub] incubator-fluo pull request #817: fixes #816 introduced better way to setup ...
Date Mon, 20 Mar 2017 20:02:47 GMT
Github user mikewalch commented on a diff in the pull request:

    https://github.com/apache/incubator-fluo/pull/817#discussion_r106993321
  
    --- Diff: modules/core/src/main/java/org/apache/fluo/core/observer/v2/ObserversV2.java
---
    @@ -0,0 +1,152 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
    + * agreements. See the NOTICE file distributed with this work for additional information
regarding
    + * copyright ownership. The ASF licenses this file to you under the Apache License, Version
2.0 (the
    + * "License"); you may not use this file except in compliance with the License. You may
obtain a
    + * copy of the License at
    + * 
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * 
    + * Unless required by applicable law or agreed to in writing, software distributed under
the License
    + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express
    + * or implied. See the License for the specific language governing permissions and limitations
under
    + * the License.
    + */
    +
    +package org.apache.fluo.core.observer.v2;
    +
    +import java.util.HashMap;
    +import java.util.HashSet;
    +import java.util.Map;
    +import java.util.Map.Entry;
    +import java.util.Objects;
    +import java.util.Set;
    +import java.util.function.BiConsumer;
    +
    +import com.google.common.base.Preconditions;
    +import com.google.gson.Gson;
    +import org.apache.curator.framework.CuratorFramework;
    +import org.apache.fluo.api.config.FluoConfiguration;
    +import org.apache.fluo.api.data.Column;
    +import org.apache.fluo.api.exceptions.FluoException;
    +import org.apache.fluo.api.observer.Observer.NotificationType;
    +import org.apache.fluo.api.observer.ObserversFactory;
    +import org.apache.fluo.core.impl.Environment;
    +import org.apache.fluo.core.observer.ConfiguredObservers;
    +import org.apache.fluo.core.observer.ObserverProvider;
    +import org.apache.fluo.core.observer.Observers;
    +import org.apache.fluo.core.util.CuratorUtil;
    +import org.apache.zookeeper.KeeperException.NoNodeException;
    +
    +import static java.nio.charset.StandardCharsets.UTF_8;
    +import static org.apache.fluo.accumulo.util.ZookeeperPath.CONFIG_FLUO_OBSERVERS2;
    +
    +/*
    + * Support for observers configured the new way.
    + */
    +public class ObserversV2 implements Observers {
    +
    +  @Override
    +  public boolean handles(FluoConfiguration config) {
    +    return !config.getObserversFactory().isEmpty();
    +  }
    +
    +  @Override
    +  public void update(CuratorFramework curator, FluoConfiguration config) throws Exception
{
    +    String obsFactoryClass = config.getObserversFactory();
    +
    +    ObserversFactory observerFactory = newObserversFactory(obsFactoryClass);
    +
    +    Map<Column, NotificationType> obsCols = new HashMap<>();
    +    BiConsumer<Column, NotificationType> obsColConsumer = (col, nt) -> {
    +      Objects.requireNonNull(col, "Observed column must be non-null");
    +      Objects.requireNonNull(nt, "Notification type must be non-null");
    +      Preconditions.checkArgument(!obsCols.containsKey(col), "Duplicate observed column
%s", col);
    +      obsCols.put(col, nt);
    +    };
    +
    +    observerFactory.getObservedColumns(
    +        new ObserverFactoryContextImpl(config.getAppConfiguration()), obsColConsumer);
    +
    +    // TODO does core depend on GSon? If not, do we want to add dep?
    --- End diff --
    
    should remove this comment as you added it as a dependency


---
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