streams-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robdouglas <...@git.apache.org>
Subject [GitHub] incubator-streams pull request: Gplus
Date Fri, 07 Nov 2014 15:37:53 GMT
Github user robdouglas commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/122#discussion_r20016669
  
    --- Diff: streams-contrib/streams-provider-google/google-gplus/src/main/java/com/google/gplus/provider/AbstractGPlusProvider.java
---
    @@ -0,0 +1,234 @@
    +/*
    + * 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
    + *
    + *   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 com.google.gplus.provider;
    +
    +import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;
    +import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
    +import com.google.api.client.googleapis.auth.oauth2.GoogleTokenResponse;
    +import com.google.api.client.http.HttpTransport;
    +import com.google.api.client.http.javanet.NetHttpTransport;
    +import com.google.api.client.json.jackson2.JacksonFactory;
    +import com.google.api.services.plus.Plus;
    +import com.google.common.annotations.VisibleForTesting;
    +import com.google.common.base.Preconditions;
    +import com.google.common.collect.Lists;
    +import com.google.gson.Gson;
    +import com.typesafe.config.Config;
    +import org.apache.streams.config.StreamsConfigurator;
    +import org.apache.streams.core.StreamsDatum;
    +import org.apache.streams.core.StreamsProvider;
    +import org.apache.streams.core.StreamsResultSet;
    +import org.apache.streams.google.gplus.GPlusConfiguration;
    +import org.apache.streams.google.gplus.configuration.UserInfo;
    +import org.apache.streams.util.ComponentUtils;
    +import org.apache.streams.util.api.requests.backoff.BackOffStrategy;
    +import org.apache.streams.util.api.requests.backoff.impl.ExponentialBackOffStrategy;
    +import org.joda.time.DateTime;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.IOException;
    +import java.math.BigInteger;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Set;
    +import java.util.concurrent.*;
    +import java.util.concurrent.atomic.AtomicBoolean;
    +
    +/**
    + * Provider that creates a GPlus client and will run task that queue data to an outing
queue
    + */
    +public abstract class AbstractGPlusProvider implements StreamsProvider {
    +
    +    private final static Logger LOGGER = LoggerFactory.getLogger(AbstractGPlusProvider.class);
    +    private final static String SCOPE = "https://www.googleapis.com/auth/plus.stream.read";
    +    private final static int MAX_BATCH_SIZE = 1000;
    +
    +    private static final HttpTransport TRANSPORT = new NetHttpTransport();
    +    private static final JacksonFactory JSON_FACTORY = new JacksonFactory();
    +    private static final Gson GSON = new Gson();
    +
    +    private GPlusConfiguration config;
    +    private ExecutorService executor;
    +    private BlockingQueue<StreamsDatum> datumQueue;
    +    private BlockingQueue<Runnable> runnables;
    +    private AtomicBoolean isComplete;
    +    private boolean previousPullWasEmpty;
    +
    +    protected GoogleClientSecrets clientSecrets;
    +    protected GoogleCredential credential;
    +    protected Plus plus;
    +
    +
    +
    +    public AbstractGPlusProvider() {
    +        Config config = StreamsConfigurator.config.getConfig("gplus");
    +        this.config = GPlusConfigurator.detectConfiguration(config);
    +    }
    +
    +    public AbstractGPlusProvider(GPlusConfiguration config) {
    +        this.config = config;
    +    }
    +
    +    @Override
    +    public void startStream() {
    +        BackOffStrategy backOffStrategy = new ExponentialBackOffStrategy(2);
    --- End diff --
    
    Is this a magic number?


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