streams-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rbnks <...@git.apache.org>
Subject [GitHub] incubator-streams pull request: STREAMS-274 | Created all necessar...
Date Mon, 09 Feb 2015 21:10:39 GMT
Github user rbnks commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/176#discussion_r24365617
  
    --- Diff: streams-contrib/streams-provider-youtube/src/main/java/com/youtube/processor/YoutubeTypeConverter.java
---
    @@ -0,0 +1,110 @@
    +/*
    + * 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.youtube.processor;
    +
    +import com.fasterxml.jackson.databind.module.SimpleModule;
    +import com.google.api.services.youtube.model.Video;
    +import com.google.common.collect.Lists;
    +import com.youtube.serializer.YoutubeActivityUtil;
    +import com.youtube.serializer.YoutubeEventClassifier;
    +import com.youtube.serializer.YoutubeVideoDeserializer;
    +import org.apache.streams.core.StreamsDatum;
    +import org.apache.streams.core.StreamsProcessor;
    +import org.apache.streams.jackson.StreamsJacksonMapper;
    +import org.apache.streams.pojo.json.Activity;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.List;
    +import java.util.Queue;
    +
    +public class YoutubeTypeConverter implements StreamsProcessor {
    +    public final static String STREAMS_ID = "YoutubeTypeConverter";
    +
    +    private final static Logger LOGGER = LoggerFactory.getLogger(YoutubeTypeConverter.class);
    +    private StreamsJacksonMapper mapper;
    +    private Queue<Video> inQueue;
    +    private Queue<StreamsDatum> outQueue;
    +    private YoutubeActivityUtil youtubeActivityUtil;
    +    private int count = 0;
    +
    +    public YoutubeTypeConverter() {}
    +
    +
    +    @Override
    +    public List<StreamsDatum> process(StreamsDatum streamsDatum) {
    +        StreamsDatum result = null;
    +
    +        try {
    +            Object item = streamsDatum.getDocument();
    +
    +            LOGGER.debug("{} processing {}", STREAMS_ID, item.getClass());
    +            Activity activity = null;
    +
    +            if(item instanceof String) {
    +                item = deserializeItem(item);
    +            }
    +
    +            if(item instanceof Video) {
    +                activity = new Activity();
    +                youtubeActivityUtil.updateActivity((Video)item, activity, streamsDatum.getId());
    +            }
    +
    +            if(activity != null) {
    +                result = new StreamsDatum(activity);
    +                count++;
    +            }
    +        } catch (Exception e) {
    +            e.printStackTrace();
    --- End diff --
    
    Instead of logging just the error message and printing the stacktrace to the error stream,
can we log the entire stacktrace?  ("message', e)


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