// Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
// 
//     void prepare(Map conf, TopologyContext topologyContext);
// 
//     /**
//      * Returns the filename the HdfsBolt will create.
//      * @param rotation the current file rotation number (incremented on every rotation)
//      * @param timeStamp current time in milliseconds when the rotation occurs
//      * @return
//      */
//     String getName(long rotation, long timeStamp);
// 
//     String getPath();
// }
// 
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
//     /**
//      * Called for every tuple the HdfsBolt executes.
//      *
//      * @param tuple The tuple executed.
//      * @param offset current offset of file being written
//      * @return true if a file rotation should be performed
//      */
//     boolean mark(Tuple tuple, long offset);
// 
// 
//     /**
//      * Called after the HdfsBolt rotates a file.
//      *
//      */
//     void reset();
// }
// 
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/TimedRotationPolicy.java
// public class TimedRotationPolicy implements FileRotationPolicy {
// 
//     public static enum TimeUnit {
// 
//         SECONDS((long)1000),
//         MINUTES((long)1000*60),
//         HOURS((long)1000*60*60),
//         DAYS((long)1000*60*60*24);
// 
//         private long milliSeconds;
// 
//         private TimeUnit(long milliSeconds){
//             this.milliSeconds = milliSeconds;
//         }
// 
//         public long getMilliSeconds(){
//             return milliSeconds;
//         }
//     }
// 
//     private long interval;
// 
//     public TimedRotationPolicy(float count, TimeUnit units){
//         this.interval = (long)(count * units.getMilliSeconds());
//     }
// 
// 
//     /**
//      * Called for every tuple the HdfsBolt executes.
//      *
//      * @param tuple  The tuple executed.
//      * @param offset current offset of file being written
//      * @return true if a file rotation should be performed
//      */
//     @Override
//     public boolean mark(Tuple tuple, long offset) {
//         return false;
//     }
// 
//     /**
//      * Called after the HdfsBolt rotates a file.
//      */
//     @Override
//     public void reset() {
// 
//     }
// 
//     public long getInterval(){
//         return this.interval;
//     }
// }
// 
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
//     /**
//      * Called for every tuple the HdfsBolt executes.
//      *
//      * @param tuple The tuple executed.
//      * @param offset current offset for the file being written
//      * @return true if a sync should be performed
//      */
//     boolean mark(Tuple tuple, long offset);
// 
// 
//     /**
//      * Called after the HdfsBolt performs a sync.
//      *
//      */
//     void reset();
// 
// }
// 
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
//     void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
// 
// Path: src/main/java/org/apache/storm/hdfs/common/security/HdfsSecurityUtil.java
// public class HdfsSecurityUtil {
//     public static final String STORM_KEYTAB_FILE_KEY = "hdfs.keytab.file";
//     public static final String STORM_USER_NAME_KEY = "hdfs.kerberos.principal";
// 
//     public static void login(Map conf, Configuration hdfsConfig) throws IOException {
//         if (UserGroupInformation.isSecurityEnabled()) {
//             String keytab = (String) conf.get(STORM_KEYTAB_FILE_KEY);
//             if (keytab != null) {
//               hdfsConfig.set(STORM_KEYTAB_FILE_KEY, keytab);
//             }
//             String userName = (String) conf.get(STORM_USER_NAME_KEY);
//             if (userName != null) {
//               hdfsConfig.set(STORM_USER_NAME_KEY, userName);
//             }
//             SecurityUtil.login(hdfsConfig, STORM_KEYTAB_FILE_KEY, STORM_USER_NAME_KEY);
//         }
//     }
// }


import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichBolt;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.rotation.TimedRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.apache.storm.hdfs.common.security.HdfsSecurityUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
/**
 * 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.storm.hdfs.bolt;



public abstract class AbstractHdfsBolt extends BaseRichBolt {
    private static final Logger LOG = LoggerFactory.getLogger(AbstractHdfsBolt.class);

// Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
// 
//     void prepare(Map conf, TopologyContext topologyContext);
// 
//     /**
//      * Returns the filename the HdfsBolt will create.
//      * @param rotation the current file rotation number (incremented on every rotation)
//      * @param timeStamp current time in milliseconds when the rotation occurs
//      * @return
//      */
//     String getName(long rotation, long timeStamp);
// 
//     String getPath();
// }
// 
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
//     /**
//      * Called for every tuple the HdfsBolt executes.
//      *
//      * @param tuple The tuple executed.
//      * @param offset current offset of file being written
//      * @return true if a file rotation should be performed
//      */
//     boolean mark(Tuple tuple, long offset);
// 
// 
//     /**
//      * Called after the HdfsBolt rotates a file.
//      *
//      */
//     void reset();
// }
// 
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/TimedRotationPolicy.java
// public class TimedRotationPolicy implements FileRotationPolicy {
// 
//     public static enum TimeUnit {
// 
//         SECONDS((long)1000),
//         MINUTES((long)1000*60),
//         HOURS((long)1000*60*60),
//         DAYS((long)1000*60*60*24);
// 
//         private long milliSeconds;
// 
//         private TimeUnit(long milliSeconds){
//             this.milliSeconds = milliSeconds;
//         }
// 
//         public long getMilliSeconds(){
//             return milliSeconds;
//         }
//     }
// 
//     private long interval;
// 
//     public TimedRotationPolicy(float count, TimeUnit units){
//         this.interval = (long)(count * units.getMilliSeconds());
//     }
// 
// 
//     /**
//      * Called for every tuple the HdfsBolt executes.
//      *
//      * @param tuple  The tuple executed.
//      * @param offset current offset of file being written
//      * @return true if a file rotation should be performed
//      */
//     @Override
//     public boolean mark(Tuple tuple, long offset) {
//         return false;
//     }
// 
//     /**
//      * Called after the HdfsBolt rotates a file.
//      */
//     @Override
//     public void reset() {
// 
//     }
// 
//     public long getInterval(){
//         return this.interval;
//     }
// }
// 
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
//     /**
//      * Called for every tuple the HdfsBolt executes.
//      *
//      * @param tuple The tuple executed.
//      * @param offset current offset for the file being written
//      * @return true if a sync should be performed
//      */
//     boolean mark(Tuple tuple, long offset);
// 
// 
//     /**
//      * Called after the HdfsBolt performs a sync.
//      *
//      */
//     void reset();
// 
// }
// 
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
//     void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
// 
// Path: src/main/java/org/apache/storm/hdfs/common/security/HdfsSecurityUtil.java
// public class HdfsSecurityUtil {
//     public static final String STORM_KEYTAB_FILE_KEY = "hdfs.keytab.file";
//     public static final String STORM_USER_NAME_KEY = "hdfs.kerberos.principal";
// 
//     public static void login(Map conf, Configuration hdfsConfig) throws IOException {
//         if (UserGroupInformation.isSecurityEnabled()) {
//             String keytab = (String) conf.get(STORM_KEYTAB_FILE_KEY);
//             if (keytab != null) {
//               hdfsConfig.set(STORM_KEYTAB_FILE_KEY, keytab);
//             }
//             String userName = (String) conf.get(STORM_USER_NAME_KEY);
//             if (userName != null) {
//               hdfsConfig.set(STORM_USER_NAME_KEY, userName);
//             }
//             SecurityUtil.login(hdfsConfig, STORM_KEYTAB_FILE_KEY, STORM_USER_NAME_KEY);
//         }
//     }
// }


// Path: src/main/java/org/apache/storm/hdfs/bolt/AbstractHdfsBolt.java
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichBolt;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.rotation.TimedRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.apache.storm.hdfs.common.security.HdfsSecurityUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

/**
 * 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.storm.hdfs.bolt;



public abstract class AbstractHdfsBolt extends BaseRichBolt {
    private static final Logger LOG = LoggerFactory.getLogger(AbstractHdfsBolt.class);

    protected ArrayList<RotationAction> rotationActions = new ArrayList<RotationAction>();