001/* 002 * Copyright (c) 2018 Chris K Wensel <chris@wensel.net>. All Rights Reserved. 003 * 004 * Project and contact information: http://www.cascading.org/ 005 * 006 * This file is part of the Cascading project. 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020 021package cascading.local.tap.splunk; 022 023import java.io.InputStream; 024import java.io.OutputStream; 025import java.util.Properties; 026 027import cascading.flow.FlowProcess; 028import cascading.scheme.local.TextDelimited; 029import cascading.scheme.util.DelimitedParser; 030import cascading.tap.Tap; 031import cascading.tuple.Fields; 032import com.splunk.JobExportArgs; 033 034/** 035 * Class SplunkRawDelimited is a {@link cascading.scheme.Scheme} that enables RAW export from a Splunk instance. 036 * <p> 037 * It is a sub-class of the {@link TextDelimited} Scheme, so is intended to sink and source delimited lines of (parsed) text. 038 * See {@link SplunkRawLine} for handling of full (unparsed) log lines. 039 * <p> 040 * This Tap does not support reading/writing headers. 041 */ 042public class SplunkRawDelimited extends TextDelimited implements SplunkScheme 043 { 044 /** 045 * Instantiates a new SplunkRawDelimited. 046 */ 047 public SplunkRawDelimited() 048 { 049 } 050 051 /** 052 * Instantiates a new SplunkRawDelimited. 053 * 054 * @param delimitedParser the delimited parser 055 */ 056 public SplunkRawDelimited( DelimitedParser delimitedParser ) 057 { 058 super( delimitedParser ); 059 } 060 061 /** 062 * Instantiates a new SplunkRawDelimited. 063 * 064 * @param fields the fields 065 */ 066 public SplunkRawDelimited( Fields fields ) 067 { 068 super( fields ); 069 } 070 071 /** 072 * Instantiates a new SplunkRawDelimited. 073 * 074 * @param fields the fields 075 * @param delimiter the delimiter 076 */ 077 public SplunkRawDelimited( Fields fields, String delimiter ) 078 { 079 super( fields, delimiter ); 080 } 081 082 /** 083 * Instantiates a new SplunkRawDelimited. 084 * 085 * @param fields the fields 086 * @param delimiter the delimiter 087 * @param types the types 088 */ 089 public SplunkRawDelimited( Fields fields, String delimiter, Class[] types ) 090 { 091 super( fields, delimiter, types ); 092 } 093 094 /** 095 * Instantiates a new SplunkRawDelimited. 096 * 097 * @param fields the fields 098 * @param delimiter the delimiter 099 * @param quote the quote 100 * @param types the types 101 */ 102 public SplunkRawDelimited( Fields fields, String delimiter, String quote, Class[] types ) 103 { 104 super( fields, delimiter, quote, types ); 105 } 106 107 /** 108 * Instantiates a new SplunkRawDelimited. 109 * 110 * @param fields the fields 111 * @param delimiter the delimiter 112 * @param quote the quote 113 * @param types the types 114 * @param safe the safe 115 */ 116 public SplunkRawDelimited( Fields fields, String delimiter, String quote, Class[] types, boolean safe ) 117 { 118 super( fields, delimiter, quote, types, safe ); 119 } 120 121 /** 122 * Instantiates a new SplunkRawDelimited. 123 * 124 * @param fields the fields 125 * @param delimiter the delimiter 126 * @param quote the quote 127 */ 128 public SplunkRawDelimited( Fields fields, String delimiter, String quote ) 129 { 130 super( fields, delimiter, quote ); 131 } 132 133 @Override 134 public void sourceConfInit( FlowProcess<? extends Properties> flowProcess, Tap<Properties, InputStream, OutputStream> tap, Properties conf ) 135 { 136 super.sourceConfInit( flowProcess, tap, conf ); 137 138 JobExportArgs args = new JobExportArgs(); 139 140 args.setOutputMode( JobExportArgs.OutputMode.RAW ); 141 142 conf.put( "args", args ); 143 } 144 145 @Override 146 public Fields retrieveSourceFields( FlowProcess<? extends Properties> process, Tap tap ) 147 { 148 return getSourceFields(); 149 } 150 }