INTEXT-21 Add Splunk adapter
For reference see: https://jira.springsource.org/browse/INTEXT-21
This commit is contained in:
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
.settings/
|
||||||
|
.gradle
|
||||||
|
build
|
||||||
|
target/
|
||||||
|
bin/
|
||||||
|
derby.log
|
||||||
113
README.md
Normal file
113
README.md
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
Spring Integration Splunk Adapter
|
||||||
|
=================================================
|
||||||
|
|
||||||
|
The SI adapter includes Outbound Channel Adapter and Inbound Channel Adapter.
|
||||||
|
|
||||||
|
Inbound channel adapter :
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
Inbound channel adapter is used to get data out of Splunk and put into
|
||||||
|
Spring Integration's channel. There are 5 ways to get data out of Splunk:
|
||||||
|
* Blocking
|
||||||
|
* Non blocking
|
||||||
|
* Saved search
|
||||||
|
* Realtime
|
||||||
|
* Export
|
||||||
|
|
||||||
|
|
||||||
|
### Blocking search:
|
||||||
|
~~~~~xml
|
||||||
|
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||||
|
auto-startup="true" search="search spring:example"
|
||||||
|
splunk-server-ref="splunkServer"
|
||||||
|
channel="inputFromSplunk" mode="blocking" earliestTime="-1d" latestTime="now" initEarliestTime="-1d">
|
||||||
|
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||||
|
</int-splunk:inbound-channel-adapter>
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
### Non blocking search:
|
||||||
|
~~~~~xml
|
||||||
|
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||||
|
auto-startup="true" search="search spring:example"
|
||||||
|
splunk-server-ref="splunkServer"
|
||||||
|
channel="inputFromSplunk" mode="normal" earliestTime="-1d" latestTime="now" initEarliestTime="-1d">
|
||||||
|
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||||
|
</int-splunk:inbound-channel-adapter>
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
### Saved search:
|
||||||
|
~~~~~xml
|
||||||
|
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||||
|
auto-startup="true" savedSearch="test" splunk-server-ref="splunkServer"
|
||||||
|
channel="inputFromSplunk" mode="saved" earliestTime="-1d" latestTime="now" initEarliestTime="-1d">
|
||||||
|
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||||
|
</int-splunk:inbound-channel-adapter>
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
### Realtime search:
|
||||||
|
~~~~~xml
|
||||||
|
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||||
|
auto-startup="true" search="search spring:example" splunk-server-ref="splunkServer" channel="inputFromSplunk"
|
||||||
|
mode="realtime" earliestTime="-5s" latestTime="rt" initEarliestTime="-1d">
|
||||||
|
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||||
|
</int-splunk:inbound-channel-adapter>
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
### Export:
|
||||||
|
~~~~~xml
|
||||||
|
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||||
|
auto-startup="true" search="search spring:example" splunk-server-ref="splunkServer" channel="inputFromSplunk"
|
||||||
|
mode="export" earliestTime="-5d" latestTime="now" initEarliestTime="-1d">
|
||||||
|
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||||
|
</int-splunk:inbound-channel-adapter>
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
Outbound channel adapter:
|
||||||
|
----------------------------------------------------------------------------------------------
|
||||||
|
Outbound channel adapter is used to put data into Splunk from
|
||||||
|
channels in Spring Integration. There are 3 kinds of method to put data
|
||||||
|
* REST(submit)
|
||||||
|
* stream
|
||||||
|
* tcp
|
||||||
|
|
||||||
|
### Submit:
|
||||||
|
~~~~~xml
|
||||||
|
<int-splunk:outbound-channel-adapter
|
||||||
|
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
|
||||||
|
channel="outputToSplunk"
|
||||||
|
splunk-server-ref="splunkServer" pool-server-connection="true"
|
||||||
|
sourceType="spring-integration" source="example2" ingest="submit">
|
||||||
|
</int-splunk:outbound-channel-adapter>
|
||||||
|
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
### Stream:
|
||||||
|
~~~~~xml
|
||||||
|
<int-splunk:outbound-channel-adapter
|
||||||
|
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
|
||||||
|
channel="outputToSplunk" splunk-server-ref="splunkServer"
|
||||||
|
ingest="stream">
|
||||||
|
</int-splunk:outbound-channel-adapter>
|
||||||
|
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
### tcp
|
||||||
|
~~~~~xml
|
||||||
|
<int-splunk:outbound-channel-adapter
|
||||||
|
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
|
||||||
|
channel="outputToSplunk" splunk-server-ref="splunkServer"
|
||||||
|
ingest="tcp" tcpPort="9999">
|
||||||
|
</int-splunk:outbound-channel-adapter>
|
||||||
|
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
Development
|
||||||
|
-----------------
|
||||||
|
### To build:
|
||||||
|
|
||||||
|
./gradlew build
|
||||||
|
|
||||||
|
### To generate Eclipse metadata (.classpath and .project files), do the following:
|
||||||
|
|
||||||
|
./gradlew eclipse
|
||||||
|
|
||||||
288
build.gradle
Normal file
288
build.gradle
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
description = 'Spring Integration Splunk Adapter'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
maven { url 'http://repo.springsource.org/plugins-snapshot' }
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'org.springframework.build.gradle:docbook-reference-plugin:0.1.5'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'java'
|
||||||
|
apply from: "${rootProject.projectDir}/publish-maven.gradle"
|
||||||
|
apply plugin: 'eclipse'
|
||||||
|
apply plugin: 'idea'
|
||||||
|
|
||||||
|
group = 'org.springframework.integration'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven { url 'http://repo.springsource.org/libs-milestone' }
|
||||||
|
maven { url 'http://repo.springsource.org/plugins-release' } // for bundlor
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceCompatibility=1.5
|
||||||
|
targetCompatibility=1.5
|
||||||
|
|
||||||
|
ext {
|
||||||
|
cglibVersion = '2.2'
|
||||||
|
junitVersion = '4.8.2'
|
||||||
|
log4jVersion = '1.2.12'
|
||||||
|
mockitoVersion = '1.9.0'
|
||||||
|
springVersion = '3.1.2.RELEASE'
|
||||||
|
springIntegrationVersion = '2.1.2.RELEASE'
|
||||||
|
commonsLangVersion = '2.6'
|
||||||
|
commonsPoolVersion = '1.6'
|
||||||
|
splunkVersion = '0.8.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
// See http://www.gradle.org/docs/current/userguide/dependency_management.html#sub:configurations
|
||||||
|
// and http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.ConfigurationContainer.html
|
||||||
|
configurations {
|
||||||
|
jacoco //Configuration Group used by Sonar to provide Code Coverage using JaCoCo
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile("com.splunk:splunk:$splunkVersion")
|
||||||
|
compile "org.springframework:spring-beans:$springVersion"
|
||||||
|
compile "org.springframework:spring-context:$springVersion"
|
||||||
|
compile "org.springframework:spring-expression:$springVersion"
|
||||||
|
compile "org.springframework.integration:spring-integration-core:$springIntegrationVersion"
|
||||||
|
compile "commons-lang:commons-lang:$commonsLangVersion"
|
||||||
|
compile "commons-pool:commons-pool:$commonsPoolVersion"
|
||||||
|
|
||||||
|
testCompile "org.mockito:mockito-all:$mockitoVersion"
|
||||||
|
testCompile "org.springframework:spring-test:$springVersion"
|
||||||
|
testCompile "cglib:cglib-nodep:$cglibVersion"
|
||||||
|
testCompile "junit:junit-dep:$junitVersion"
|
||||||
|
testCompile "log4j:log4j:$log4jVersion"
|
||||||
|
testCompile "org.springframework.integration:spring-integration-stream:$springIntegrationVersion"
|
||||||
|
jacoco group: "org.jacoco", name: "org.jacoco.agent", version: "0.5.6.201201232323", classifier: "runtime"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
eclipse {
|
||||||
|
project {
|
||||||
|
natures += 'org.springframework.ide.eclipse.core.springnature'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
test {
|
||||||
|
resources {
|
||||||
|
srcDirs = ['src/test/resources', 'src/test/java']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// enable all compiler warnings; individual projects may customize further
|
||||||
|
ext.xLintArg = '-Xlint:all'
|
||||||
|
[compileJava, compileTestJava]*.options*.compilerArgs = [xLintArg]
|
||||||
|
|
||||||
|
test {
|
||||||
|
// suppress all console output during testing unless running `gradle -i`
|
||||||
|
logging.captureStandardOutput(LogLevel.INFO)
|
||||||
|
jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=*"
|
||||||
|
}
|
||||||
|
|
||||||
|
task sourcesJar(type: Jar) {
|
||||||
|
classifier = 'sources'
|
||||||
|
from sourceSets.main.allJava
|
||||||
|
}
|
||||||
|
|
||||||
|
task javadocJar(type: Jar) {
|
||||||
|
classifier = 'javadoc'
|
||||||
|
from javadoc
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives sourcesJar
|
||||||
|
archives javadocJar
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'docbook-reference'
|
||||||
|
|
||||||
|
reference {
|
||||||
|
sourceDir = file('src/reference/docbook')
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'sonar'
|
||||||
|
|
||||||
|
sonar {
|
||||||
|
|
||||||
|
if (rootProject.hasProperty('sonarHostUrl')) {
|
||||||
|
server.url = rootProject.sonarHostUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
database {
|
||||||
|
if (rootProject.hasProperty('sonarJdbcUrl')) {
|
||||||
|
url = rootProject.sonarJdbcUrl
|
||||||
|
}
|
||||||
|
if (rootProject.hasProperty('sonarJdbcDriver')) {
|
||||||
|
driverClassName = rootProject.sonarJdbcDriver
|
||||||
|
}
|
||||||
|
if (rootProject.hasProperty('sonarJdbcUsername')) {
|
||||||
|
username = rootProject.sonarJdbcUsername
|
||||||
|
}
|
||||||
|
if (rootProject.hasProperty('sonarJdbcPassword')) {
|
||||||
|
password = rootProject.sonarJdbcPassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project {
|
||||||
|
dynamicAnalysis = "reuseReports"
|
||||||
|
withProjectProperties { props ->
|
||||||
|
props["sonar.core.codeCoveragePlugin"] = "jacoco"
|
||||||
|
props["sonar.jacoco.reportPath"] = "${buildDir.name}/jacoco.exec"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("Sonar parameters used: server.url='${server.url}'; database.url='${database.url}'; database.driverClassName='${database.driverClassName}'; database.username='${database.username}'")
|
||||||
|
}
|
||||||
|
|
||||||
|
task api(type: Javadoc) {
|
||||||
|
group = 'Documentation'
|
||||||
|
description = 'Generates aggregated Javadoc API documentation.'
|
||||||
|
title = "${rootProject.description} ${version} API"
|
||||||
|
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
|
||||||
|
options.author = true
|
||||||
|
options.header = rootProject.description
|
||||||
|
options.overview = 'src/api/overview.html'
|
||||||
|
source subprojects.collect { project ->
|
||||||
|
project.sourceSets.main.allJava
|
||||||
|
}
|
||||||
|
destinationDir = new File(buildDir, "api")
|
||||||
|
classpath = files(subprojects.collect { project ->
|
||||||
|
project.sourceSets.main.compileClasspath
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
task schemaZip(type: Zip) {
|
||||||
|
group = 'Distribution'
|
||||||
|
classifier = 'schema'
|
||||||
|
description = "Builds -${classifier} archive containing all " +
|
||||||
|
"XSDs for deployment at static.springframework.org/schema."
|
||||||
|
|
||||||
|
subprojects.each { subproject ->
|
||||||
|
def Properties schemas = new Properties();
|
||||||
|
def shortName = subproject.name.replaceFirst("${rootProject.name}-", '')
|
||||||
|
if (subproject.name.endsWith("-core")) {
|
||||||
|
shortName = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
subproject.sourceSets.main.resources.find {
|
||||||
|
it.path.endsWith('META-INF/spring.schemas')
|
||||||
|
}?.withInputStream { schemas.load(it) }
|
||||||
|
|
||||||
|
for (def key : schemas.keySet()) {
|
||||||
|
File xsdFile = subproject.sourceSets.main.resources.find {
|
||||||
|
it.path.endsWith(schemas.get(key))
|
||||||
|
}
|
||||||
|
assert xsdFile != null
|
||||||
|
into ("integration/${shortName}") {
|
||||||
|
from xsdFile.path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task docsZip(type: Zip) {
|
||||||
|
group = 'Distribution'
|
||||||
|
classifier = 'docs'
|
||||||
|
description = "Builds -${classifier} archive containing api and reference " +
|
||||||
|
"for deployment at static.springframework.org/spring-integration/docs."
|
||||||
|
|
||||||
|
from('src/dist') {
|
||||||
|
include 'changelog.txt'
|
||||||
|
}
|
||||||
|
|
||||||
|
from (api) {
|
||||||
|
into 'api'
|
||||||
|
}
|
||||||
|
|
||||||
|
from (reference) {
|
||||||
|
into 'reference'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task distZip(type: Zip, dependsOn: [docsZip, schemaZip]) {
|
||||||
|
group = 'Distribution'
|
||||||
|
classifier = 'dist'
|
||||||
|
description = "Builds -${classifier} archive, containing all jars and docs, " +
|
||||||
|
"suitable for community download page."
|
||||||
|
|
||||||
|
ext.baseDir = "${project.name}-${project.version}";
|
||||||
|
|
||||||
|
from('src/dist') {
|
||||||
|
include 'readme.txt'
|
||||||
|
include 'license.txt'
|
||||||
|
include 'notice.txt'
|
||||||
|
into "${baseDir}"
|
||||||
|
}
|
||||||
|
|
||||||
|
from(zipTree(docsZip.archivePath)) {
|
||||||
|
into "${baseDir}/docs"
|
||||||
|
}
|
||||||
|
|
||||||
|
from(zipTree(schemaZip.archivePath)) {
|
||||||
|
into "${baseDir}/schema"
|
||||||
|
}
|
||||||
|
|
||||||
|
subprojects.each { subproject ->
|
||||||
|
into ("${baseDir}/libs") {
|
||||||
|
from subproject.jar
|
||||||
|
from subproject.sourcesJar
|
||||||
|
from subproject.javadocJar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create an optional "with dependencies" distribution.
|
||||||
|
// Not published by default; only for use when building from source.
|
||||||
|
task depsZip(type: Zip, dependsOn: distZip) { zipTask ->
|
||||||
|
group = 'Distribution'
|
||||||
|
classifier = 'dist-with-deps'
|
||||||
|
description = "Builds -${classifier} archive, containing everything " +
|
||||||
|
"in the -${distZip.classifier} archive plus all dependencies."
|
||||||
|
|
||||||
|
from zipTree(distZip.archivePath)
|
||||||
|
|
||||||
|
gradle.taskGraph.whenReady { taskGraph ->
|
||||||
|
if (taskGraph.hasTask(":${zipTask.name}")) {
|
||||||
|
def projectNames = rootProject.subprojects*.name
|
||||||
|
def artifacts = new HashSet()
|
||||||
|
subprojects.each { subproject ->
|
||||||
|
subproject.configurations.runtime.resolvedConfiguration.resolvedArtifacts.each { artifact ->
|
||||||
|
def dependency = artifact.moduleVersion.id
|
||||||
|
if (!projectNames.contains(dependency.name)) {
|
||||||
|
artifacts << artifact.file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zipTask.from(artifacts) {
|
||||||
|
into "${distZip.baseDir}/deps"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives distZip
|
||||||
|
archives docsZip
|
||||||
|
archives schemaZip
|
||||||
|
}
|
||||||
|
|
||||||
|
task dist(dependsOn: assemble) {
|
||||||
|
group = 'Distribution'
|
||||||
|
description = 'Builds -dist, -docs and -schema distribution archives.'
|
||||||
|
}
|
||||||
|
|
||||||
|
task wrapper(type: Wrapper) {
|
||||||
|
description = 'Generates gradlew[.bat] scripts'
|
||||||
|
gradleVersion = '1.2'
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultTasks 'build'
|
||||||
1
gradle.properties
Normal file
1
gradle.properties
Normal file
@@ -0,0 +1 @@
|
|||||||
|
version=0.5.0.BUILD-SNAPSHOT
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#Fri Sep 28 09:33:09 CST 2012
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=http\://services.gradle.org/distributions/gradle-1.2-bin.zip
|
||||||
164
gradlew
vendored
Executable file
164
gradlew
vendored
Executable file
@@ -0,0 +1,164 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn ( ) {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die ( ) {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||||
|
if $cygwin ; then
|
||||||
|
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/"
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED"
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query businessSystem maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||||
|
function splitJvmOpts() {
|
||||||
|
JVM_OPTS=("$@")
|
||||||
|
}
|
||||||
|
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||||
|
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||||
90
gradlew.bat
vendored
Normal file
90
gradlew.bat
vendored
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windowz variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
goto execute
|
||||||
|
|
||||||
|
:4NT_args
|
||||||
|
@rem Get arguments from the 4NT Shell from JP Software
|
||||||
|
set CMD_LINE_ARGS=%$
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
60
publish-maven.gradle
Normal file
60
publish-maven.gradle
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
apply plugin: 'maven'
|
||||||
|
|
||||||
|
ext.optionalDeps = []
|
||||||
|
ext.providedDeps = []
|
||||||
|
ext.optional = { optionalDeps << it }
|
||||||
|
ext.provided = { providedDeps << it }
|
||||||
|
|
||||||
|
install {
|
||||||
|
repositories.mavenInstaller {
|
||||||
|
customizePom(pom, project)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def customizePom(pom, gradleProject) {
|
||||||
|
pom.whenConfigured { generatedPom ->
|
||||||
|
// respect 'optional' and 'provided' dependencies
|
||||||
|
gradleProject.optionalDeps.each { dep ->
|
||||||
|
generatedPom.dependencies.find { it.artifactId == dep.name }?.optional = true
|
||||||
|
}
|
||||||
|
gradleProject.providedDeps.each { dep ->
|
||||||
|
generatedPom.dependencies.find { it.artifactId == dep.name }?.scope = 'provided'
|
||||||
|
}
|
||||||
|
|
||||||
|
// eliminate test-scoped dependencies (no need in maven central poms)
|
||||||
|
generatedPom.dependencies.removeAll { dep ->
|
||||||
|
dep.scope == 'test'
|
||||||
|
}
|
||||||
|
|
||||||
|
// add all items necessary for maven central publication
|
||||||
|
generatedPom.project {
|
||||||
|
name = gradleProject.description
|
||||||
|
description = gradleProject.description
|
||||||
|
url = 'https://github.com/SpringSource/spring-integration-extensions'
|
||||||
|
organization {
|
||||||
|
name = 'SpringSource'
|
||||||
|
url = 'http://springsource.org'
|
||||||
|
}
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
name 'The Apache Software License, Version 2.0'
|
||||||
|
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||||
|
distribution 'repo'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scm {
|
||||||
|
url = 'https://github.com/SpringSource/spring-integration-extensions'
|
||||||
|
connection = 'scm:git:git://github.com/SpringSource/spring-integration-extensions'
|
||||||
|
developerConnection = 'scm:git:git://github.com/SpringSource/spring-integration-extensions'
|
||||||
|
}
|
||||||
|
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id = 'Jarred'
|
||||||
|
name = 'Jarred Li'
|
||||||
|
email = 'leejianwei@126.com'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/api/overview.html
Normal file
22
src/api/overview.html
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
This document is the API specification for Spring Integration
|
||||||
|
<hr/>
|
||||||
|
<div id="overviewBody">
|
||||||
|
<p>
|
||||||
|
For further API reference and developer documentation, see the
|
||||||
|
<a href="http://static.springsource.org/spring-integration/reference" target="_top">Spring
|
||||||
|
Integration reference documentation</a>.
|
||||||
|
That documentation contains more detailed, developer-targeted
|
||||||
|
descriptions, with conceptual overviews, definitions of terms,
|
||||||
|
workarounds, and working code examples.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If you are interested in commercial training, consultancy, and
|
||||||
|
support for Spring Integration, please visit <a href="http://www.springsource.com" target="_top">
|
||||||
|
http://www.springsource.com</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
8
src/dist/changelog.txt
vendored
Normal file
8
src/dist/changelog.txt
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
Spring Integration Splunk Adapter CHANGELOG
|
||||||
|
=========================================
|
||||||
|
|
||||||
|
Features in version 1.0.0
|
||||||
|
|
||||||
|
1. Inbound channel adapter with 5 different ways to search data: bloking, normal(non-blocking), realtime, export, saved search.
|
||||||
|
|
||||||
|
2. Outbound channel adapter with 3 ways to push event data: Stream, tcp, REST
|
||||||
201
src/dist/license.txt
vendored
Normal file
201
src/dist/license.txt
vendored
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed 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.
|
||||||
21
src/dist/notice.txt
vendored
Normal file
21
src/dist/notice.txt
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
========================================================================
|
||||||
|
== NOTICE file corresponding to section 4 d of the Apache License, ==
|
||||||
|
== Version 2.0, in this case for the Spring Integration distribution. ==
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
This product includes software developed by
|
||||||
|
the Apache Software Foundation (http://www.apache.org).
|
||||||
|
|
||||||
|
The end-user documentation included with a redistribution, if any,
|
||||||
|
must include the following acknowledgement:
|
||||||
|
|
||||||
|
"This product includes software developed by the Spring Framework
|
||||||
|
Project (http://www.springframework.org)."
|
||||||
|
|
||||||
|
Alternatively, this acknowledgement may appear in the software itself,
|
||||||
|
if and wherever such third-party acknowledgements normally appear.
|
||||||
|
|
||||||
|
The names "Spring", "Spring Framework", and "Spring Integration" must
|
||||||
|
not be used to endorse or promote products derived from this software
|
||||||
|
without prior written permission. For written permission, please contact
|
||||||
|
enquiries@springsource.com.
|
||||||
13
src/dist/readme.txt
vendored
Normal file
13
src/dist/readme.txt
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Spring Integration Splunk Adapter
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
To find out what has changed since any earlier releases, see 'changelog.txt'.
|
||||||
|
|
||||||
|
Please consult the documentation located within the 'docs/reference' directory
|
||||||
|
of this release and also visit the official Spring Integration home at
|
||||||
|
http://www.springsource.org/spring-integration
|
||||||
|
|
||||||
|
There you will find links to the forum, issue tracker, and several other resources.
|
||||||
|
|
||||||
|
See https://github.com/SpringSource/spring-integration#readme for additional
|
||||||
|
information including instructions on building from source.
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.config.xml;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeanMetadataElement;
|
||||||
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||||
|
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||||
|
import org.springframework.beans.factory.xml.ParserContext;
|
||||||
|
import org.springframework.integration.config.xml.AbstractPollingInboundChannelAdapterParser;
|
||||||
|
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||||
|
import org.springframework.integration.splunk.inbound.SplunkPollingChannelAdapter;
|
||||||
|
import org.springframework.integration.splunk.support.ConnectionFactoryFactoryBean;
|
||||||
|
import org.springframework.integration.splunk.support.SplunkConnectionFactory;
|
||||||
|
import org.springframework.integration.splunk.support.SplunkDataReader;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Splunk Inbound Channel adapter parser
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkInboundChannelAdapterParser extends AbstractPollingInboundChannelAdapterParser {
|
||||||
|
|
||||||
|
|
||||||
|
protected BeanMetadataElement parseSource(Element element, ParserContext parserContext) {
|
||||||
|
|
||||||
|
BeanDefinitionBuilder splunkPollingChannelAdapterBuilder = BeanDefinitionBuilder.genericBeanDefinition(SplunkPollingChannelAdapter.class);
|
||||||
|
|
||||||
|
BeanDefinitionBuilder splunkExecutorBuilder = SplunkParserUtils.getSplunkExecutorBuilder(element, parserContext);
|
||||||
|
|
||||||
|
BeanDefinitionBuilder splunkDataReaderBuilder = BeanDefinitionBuilder.genericBeanDefinition(SplunkDataReader.class);
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(splunkDataReaderBuilder, element, "mode");
|
||||||
|
String count = element.getAttribute("count");
|
||||||
|
if (StringUtils.hasText(count)) {
|
||||||
|
splunkDataReaderBuilder.addPropertyValue("count", count);
|
||||||
|
}
|
||||||
|
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(splunkDataReaderBuilder, element, "fieldList");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(splunkDataReaderBuilder, element, "search");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(splunkDataReaderBuilder, element, "savedSearch");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(splunkDataReaderBuilder, element, "owner");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(splunkDataReaderBuilder, element, "app");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(splunkDataReaderBuilder, element, "initEarliestTime");
|
||||||
|
|
||||||
|
String earliestTime = element.getAttribute("earliestTime");
|
||||||
|
if (StringUtils.hasText(earliestTime)) {
|
||||||
|
splunkDataReaderBuilder.addPropertyValue("earliestTime", earliestTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
String latestTime = element.getAttribute("latestTime");
|
||||||
|
if (StringUtils.hasText(latestTime)) {
|
||||||
|
splunkDataReaderBuilder.addPropertyValue("latestTime", latestTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BeanDefinitionBuilder connectionFactoryBuilder = BeanDefinitionBuilder.genericBeanDefinition(SplunkConnectionFactory.class);
|
||||||
|
|
||||||
|
String splunkServerBeanName = element.getAttribute("splunk-server-ref");
|
||||||
|
if (StringUtils.hasText(splunkServerBeanName)) {
|
||||||
|
connectionFactoryBuilder.addConstructorArgReference(splunkServerBeanName);
|
||||||
|
}
|
||||||
|
|
||||||
|
BeanDefinitionBuilder connectionFactoryFactoryBeanBuilder = BeanDefinitionBuilder.genericBeanDefinition(ConnectionFactoryFactoryBean.class);
|
||||||
|
connectionFactoryFactoryBeanBuilder.addConstructorArgValue(connectionFactoryBuilder.getBeanDefinition());
|
||||||
|
connectionFactoryFactoryBeanBuilder.addConstructorArgValue(element.getAttribute("pool-server-connection"));
|
||||||
|
splunkDataReaderBuilder.addConstructorArgValue(connectionFactoryFactoryBeanBuilder.getBeanDefinition());
|
||||||
|
|
||||||
|
String channelAdapterId = this.resolveId(element, splunkPollingChannelAdapterBuilder.getRawBeanDefinition(),
|
||||||
|
parserContext);
|
||||||
|
String splunkExecutorBeanName = channelAdapterId + ".splunkExecutor";
|
||||||
|
String splunkDataReaderBeanName = splunkExecutorBeanName + ".reader";
|
||||||
|
|
||||||
|
parserContext.registerBeanComponent(new BeanComponentDefinition(splunkDataReaderBuilder.getBeanDefinition(),
|
||||||
|
splunkDataReaderBeanName));
|
||||||
|
splunkExecutorBuilder.addPropertyReference("reader", splunkDataReaderBeanName);
|
||||||
|
|
||||||
|
BeanDefinition splunkExecutorBuilderBeanDefinition = splunkExecutorBuilder.getBeanDefinition();
|
||||||
|
parserContext.registerBeanComponent(new BeanComponentDefinition(splunkExecutorBuilderBeanDefinition,
|
||||||
|
splunkExecutorBeanName));
|
||||||
|
|
||||||
|
splunkPollingChannelAdapterBuilder.addConstructorArgReference(splunkExecutorBeanName);
|
||||||
|
|
||||||
|
return splunkPollingChannelAdapterBuilder.getBeanDefinition();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.config.xml;
|
||||||
|
|
||||||
|
import org.springframework.integration.config.xml.AbstractIntegrationNamespaceHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The namespace handler for the Splunk namespace
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkNamespaceHandler extends AbstractIntegrationNamespaceHandler {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.beans.factory.xml.NamespaceHandler#init()
|
||||||
|
*/
|
||||||
|
public void init() {
|
||||||
|
registerBeanDefinitionParser("server", new SplunkServerParser());
|
||||||
|
this.registerBeanDefinitionParser("inbound-channel-adapter", new SplunkInboundChannelAdapterParser());
|
||||||
|
this.registerBeanDefinitionParser("outbound-channel-adapter", new SplunkOutboundChannelAdapterParser());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.config.xml;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||||
|
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||||
|
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||||
|
import org.springframework.beans.factory.xml.ParserContext;
|
||||||
|
import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
|
||||||
|
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||||
|
import org.springframework.integration.splunk.outbound.SplunkOutboundChannelAdapter;
|
||||||
|
import org.springframework.integration.splunk.support.ConnectionFactoryFactoryBean;
|
||||||
|
import org.springframework.integration.splunk.support.SplunkDataWriter;
|
||||||
|
import org.springframework.integration.splunk.support.SplunkConnectionFactory;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The parser for the Splunk Outbound Channel Adapter.
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean shouldGenerateId() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean shouldGenerateIdAsFallback() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
|
||||||
|
|
||||||
|
BeanDefinitionBuilder splunkOutboundChannelAdapterBuilder = BeanDefinitionBuilder.genericBeanDefinition(SplunkOutboundChannelAdapter.class);
|
||||||
|
BeanDefinitionBuilder splunkExecutorBuilder = SplunkParserUtils.getSplunkExecutorBuilder(element, parserContext);
|
||||||
|
|
||||||
|
BeanDefinitionBuilder splunkDataWriterBuilder = BeanDefinitionBuilder.genericBeanDefinition(SplunkDataWriter.class);
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(splunkDataWriterBuilder, element, "sourceType");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(splunkDataWriterBuilder, element, "source");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(splunkDataWriterBuilder, element, "index");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(splunkDataWriterBuilder, element, "ingest");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(splunkDataWriterBuilder, element, "tcpPort");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(splunkDataWriterBuilder, element, "host");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(splunkDataWriterBuilder, element, "hostRegex");
|
||||||
|
BeanDefinitionBuilder connectionFactoryBuilder = BeanDefinitionBuilder.genericBeanDefinition(SplunkConnectionFactory.class);
|
||||||
|
|
||||||
|
String splunkServerBeanName = element.getAttribute("splunk-server-ref");
|
||||||
|
if (StringUtils.hasText(splunkServerBeanName)) {
|
||||||
|
connectionFactoryBuilder.addConstructorArgReference(splunkServerBeanName);
|
||||||
|
}
|
||||||
|
|
||||||
|
BeanDefinitionBuilder connectionFactoryFactoryBeanBuilder = BeanDefinitionBuilder.genericBeanDefinition(ConnectionFactoryFactoryBean.class);
|
||||||
|
connectionFactoryFactoryBeanBuilder.addConstructorArgValue(connectionFactoryBuilder.getBeanDefinition());
|
||||||
|
connectionFactoryFactoryBeanBuilder.addConstructorArgValue(element.getAttribute("pool-server-connection"));
|
||||||
|
splunkDataWriterBuilder.addConstructorArgValue(connectionFactoryFactoryBeanBuilder.getBeanDefinition());
|
||||||
|
|
||||||
|
String channelAdapterId = this.resolveId(element, splunkOutboundChannelAdapterBuilder.getRawBeanDefinition(),
|
||||||
|
parserContext);
|
||||||
|
String splunkExecutorBeanName = channelAdapterId + ".splunkExecutor";
|
||||||
|
String splunkDataWriterBeanName = splunkExecutorBeanName + ".writer";
|
||||||
|
|
||||||
|
parserContext.registerBeanComponent(new BeanComponentDefinition(splunkDataWriterBuilder.getBeanDefinition(),
|
||||||
|
splunkDataWriterBeanName));
|
||||||
|
splunkExecutorBuilder.addPropertyReference("writer", splunkDataWriterBeanName);
|
||||||
|
|
||||||
|
BeanDefinition splunkExecutorBuilderBeanDefinition = splunkExecutorBuilder.getBeanDefinition();
|
||||||
|
parserContext.registerBeanComponent(new BeanComponentDefinition(splunkExecutorBuilderBeanDefinition,
|
||||||
|
splunkExecutorBeanName));
|
||||||
|
|
||||||
|
splunkOutboundChannelAdapterBuilder.addConstructorArgReference(splunkExecutorBeanName);
|
||||||
|
splunkOutboundChannelAdapterBuilder.addPropertyValue("producesReply", Boolean.FALSE);
|
||||||
|
|
||||||
|
return splunkOutboundChannelAdapterBuilder.getBeanDefinition();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.config.xml;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||||
|
import org.springframework.beans.factory.xml.ParserContext;
|
||||||
|
import org.springframework.integration.splunk.support.SplunkExecutor;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains various utility methods for parsing Splunk Adapter
|
||||||
|
* specific namesspace elements as well as for the generation of the
|
||||||
|
* respective {@link BeanDefinition}s.
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class SplunkParserUtils {
|
||||||
|
|
||||||
|
/** Prevent instantiation. */
|
||||||
|
private SplunkParserUtils() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new {@link BeanDefinitionBuilder} for the class {@link SplunkExecutor}.
|
||||||
|
* Initialize the wrapped {@link SplunkExecutor} with common properties.
|
||||||
|
*
|
||||||
|
* @param element Must not be null
|
||||||
|
* @param parserContext Must not be null
|
||||||
|
* @return The BeanDefinitionBuilder for the SplunkExecutor
|
||||||
|
*/
|
||||||
|
public static BeanDefinitionBuilder getSplunkExecutorBuilder(final Element element, final ParserContext parserContext) {
|
||||||
|
|
||||||
|
Assert.notNull(element, "The provided element must not be null.");
|
||||||
|
Assert.notNull(parserContext, "The provided parserContext must not be null.");
|
||||||
|
|
||||||
|
final BeanDefinitionBuilder splunkExecutorBuilder = BeanDefinitionBuilder.genericBeanDefinition(SplunkExecutor.class);
|
||||||
|
|
||||||
|
return splunkExecutorBuilder;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.config.xml;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||||
|
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
|
||||||
|
import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
|
||||||
|
import org.springframework.beans.factory.xml.ParserContext;
|
||||||
|
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkServer;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Splunk server element parser.
|
||||||
|
*
|
||||||
|
* The XML element is like this:
|
||||||
|
* <pre>
|
||||||
|
* {@code
|
||||||
|
* <splunk:server id="splunkServer" host="host" port="8089" userName="admin" password="password"
|
||||||
|
* scheme="https" owner="admin" app="search"/>
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkServerParser extends AbstractSimpleBeanDefinitionParser {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getBeanClass(Element element) {
|
||||||
|
return SplunkServer.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||||
|
super.doParse(element, parserContext, builder);
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element,
|
||||||
|
BeanDefinitionParserDelegate.SCOPE_ATTRIBUTE);
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "host");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "port");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "scheme");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "app");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "owner");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "userName");
|
||||||
|
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "password");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* Provides parser classes to provide Xml namespace support for the Splunk components.
|
||||||
|
*/
|
||||||
|
package org.springframework.integration.splunk.config.xml;
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.core;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connection to Splunk service
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface Connection<T> {
|
||||||
|
|
||||||
|
T getTarget();
|
||||||
|
|
||||||
|
void close();
|
||||||
|
|
||||||
|
boolean isOpen();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory pattern to create <code>Connection</code>
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface ConnectionFactory<T> {
|
||||||
|
|
||||||
|
Connection<T> getConnection() throws Exception;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.core;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data reader to read Splunk data from the service.
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
public interface DataReader {
|
||||||
|
|
||||||
|
List<SplunkData> search() throws Exception;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.core;
|
||||||
|
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data writer to write Splunk data into Splunk
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface DataWriter {
|
||||||
|
|
||||||
|
void write(SplunkData data) throws Exception;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* Provides core classes of the Splunk module.
|
||||||
|
*/
|
||||||
|
package org.springframework.integration.splunk.core;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Splunk server entity
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkServer {
|
||||||
|
|
||||||
|
private String host;
|
||||||
|
private int port;
|
||||||
|
private String scheme;
|
||||||
|
private String app;
|
||||||
|
private String owner;
|
||||||
|
private String userName;
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the host
|
||||||
|
*/
|
||||||
|
public String getHost() {
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param host the host to set
|
||||||
|
*/
|
||||||
|
public void setHost(String host) {
|
||||||
|
this.host = host;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the port
|
||||||
|
*/
|
||||||
|
public int getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param port the port to set
|
||||||
|
*/
|
||||||
|
public void setPort(int port) {
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getScheme() {
|
||||||
|
return scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScheme(String scheme) {
|
||||||
|
this.scheme = scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApp() {
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApp(String app) {
|
||||||
|
this.app = app;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOwner(String owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the userName
|
||||||
|
*/
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param userName the userName to set
|
||||||
|
*/
|
||||||
|
public void setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the password
|
||||||
|
*/
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param password the password to set
|
||||||
|
*/
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.inbound;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.integration.Message;
|
||||||
|
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||||
|
import org.springframework.integration.core.MessageSource;
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkData;
|
||||||
|
import org.springframework.integration.splunk.support.SplunkExecutor;
|
||||||
|
import org.springframework.integration.support.MessageBuilder;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Polling data from Splunk to generate <code>Message</code>
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkPollingChannelAdapter extends IntegrationObjectSupport implements MessageSource<List<SplunkData>> {
|
||||||
|
|
||||||
|
private final SplunkExecutor splunkExecutor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor taking a {@link SplunkExecutor} that provide all required Splunk
|
||||||
|
* functionality.
|
||||||
|
*
|
||||||
|
* @param splunkExecutor Must not be null.
|
||||||
|
*/
|
||||||
|
public SplunkPollingChannelAdapter(SplunkExecutor splunkExecutor) {
|
||||||
|
super();
|
||||||
|
Assert.notNull(splunkExecutor, "splunkExecutor must not be null.");
|
||||||
|
this.splunkExecutor = splunkExecutor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for mandatory attributes
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void onInit() throws Exception {
|
||||||
|
super.onInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses {@link SplunkExecutor#poll()} to executes the Splunk operation.
|
||||||
|
*
|
||||||
|
* If {@link SplunkExecutor#poll()} returns null, this method will return
|
||||||
|
* <code>null</code>. Otherwise, a new {@link Message} is constructed and returned.
|
||||||
|
*/
|
||||||
|
public Message<List<SplunkData>> receive() {
|
||||||
|
List<SplunkData> payload = splunkExecutor.poll();
|
||||||
|
if (payload == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return MessageBuilder.withPayload(payload).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getComponentType() {
|
||||||
|
return "splunk:inbound-channel-adapter";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* Provides inbound Spring Integration Splunk components.
|
||||||
|
*/
|
||||||
|
package org.springframework.integration.splunk.inbound;
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.outbound;
|
||||||
|
|
||||||
|
import org.springframework.integration.Message;
|
||||||
|
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||||
|
import org.springframework.integration.splunk.support.SplunkExecutor;
|
||||||
|
import org.springframework.integration.support.MessageBuilder;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle message and write data into Splunk
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkOutboundChannelAdapter extends AbstractReplyProducingMessageHandler {
|
||||||
|
|
||||||
|
private final SplunkExecutor splunkExecutor;
|
||||||
|
private boolean producesReply = true; //false for outbound-channel-adapter, true for outbound-gateway
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor taking an {@link SplunkExecutor} that wraps common
|
||||||
|
* Splunk Operations.
|
||||||
|
*
|
||||||
|
* @param splunkExecutor Must not be null
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public SplunkOutboundChannelAdapter(SplunkExecutor splunkExecutor) {
|
||||||
|
Assert.notNull(splunkExecutor, "splunkExecutor must not be null.");
|
||||||
|
this.splunkExecutor = splunkExecutor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Object handleRequestMessage(Message<?> requestMessage) {
|
||||||
|
final Object result;
|
||||||
|
result = this.splunkExecutor.executeOutboundOperation(requestMessage);
|
||||||
|
if (result == null || !producesReply) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return MessageBuilder.withPayload(result).copyHeaders(requestMessage.getHeaders()).build();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If set to 'false', this component will act as an Outbound Channel Adapter.
|
||||||
|
* If not explicitly set this property will default to 'true'.
|
||||||
|
*
|
||||||
|
* @param producesReply Defaults to 'true'.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setProducesReply(boolean producesReply) {
|
||||||
|
this.producesReply = producesReply;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* Provides Spring Integration components for doing outbound operations.
|
||||||
|
*/
|
||||||
|
package org.springframework.integration.splunk.outbound;
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.support;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
|
import org.springframework.integration.splunk.core.ConnectionFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory bean to create <code>ConnectionFactory</code>.
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ConnectionFactoryFactoryBean<T> implements FactoryBean<ConnectionFactory<T>> {
|
||||||
|
|
||||||
|
private final ConnectionFactory<T> connectionFactory;
|
||||||
|
|
||||||
|
public ConnectionFactoryFactoryBean(ConnectionFactory<T> cf, boolean usePool) {
|
||||||
|
if (usePool) {
|
||||||
|
this.connectionFactory = new PoolingConnectionFactory<T>(cf);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.connectionFactory = cf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.beans.factory.FactoryBean#getObject()
|
||||||
|
*/
|
||||||
|
public ConnectionFactory<T> getObject() throws Exception {
|
||||||
|
return this.connectionFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
|
||||||
|
*/
|
||||||
|
public Class<?> getObjectType() {
|
||||||
|
return connectionFactory.getClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.beans.factory.FactoryBean#isSingleton()
|
||||||
|
*/
|
||||||
|
public boolean isSingleton() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.support;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method of pushing data into Splunk.
|
||||||
|
*
|
||||||
|
* Stream: Establish a connection, keep it open, and stream events until the connection is closed.Better for high volume input.
|
||||||
|
* Tcp: Create raw socket and send event data into the socket
|
||||||
|
* Submit: Send event data into Splunk with HTTP REST api
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum IngestType {
|
||||||
|
stream("stream"), tcp("tcp"), submit("submit");
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
IngestType(String ingestType) {
|
||||||
|
this.type = ingestType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIngestType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.support;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.apache.commons.pool.BasePoolableObjectFactory;
|
||||||
|
import org.apache.commons.pool.ObjectPool;
|
||||||
|
import org.apache.commons.pool.impl.GenericObjectPool;
|
||||||
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
|
import org.springframework.integration.splunk.core.Connection;
|
||||||
|
import org.springframework.integration.splunk.core.ConnectionFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pooling ConnectionFactory to pool <code>Connection</code> with Apache Commons Pool.
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PoolingConnectionFactory<T> implements ConnectionFactory<T>, DisposableBean {
|
||||||
|
|
||||||
|
private final Log log = LogFactory.getLog(this.getClass());
|
||||||
|
|
||||||
|
private final ConnectionFactory<T> connectionFactory;
|
||||||
|
|
||||||
|
private ObjectPool<Connection<T>> pool;
|
||||||
|
|
||||||
|
public PoolingConnectionFactory(ConnectionFactory<T> f) {
|
||||||
|
this.connectionFactory = f;
|
||||||
|
this.pool = new GenericObjectPool<Connection<T>>(new ConnectionPoolableObjectFactory());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.ServiceFactory#getService()
|
||||||
|
*/
|
||||||
|
public Connection<T> getConnection() throws Exception {
|
||||||
|
return new PooledConnection(this.pool.borrowObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.beans.factory.DisposableBean#destroy()
|
||||||
|
*/
|
||||||
|
public void destroy() throws Exception {
|
||||||
|
pool.clear();
|
||||||
|
pool.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectionPoolableObjectFactory extends BasePoolableObjectFactory<Connection<T>> {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.apache.commons.pool.BasePoolableObjectFactory#makeObject()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Connection<T> makeObject() throws Exception {
|
||||||
|
return connectionFactory.getConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroyObject(Connection<T> obj) throws Exception {
|
||||||
|
obj.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the object is valid or not.
|
||||||
|
*
|
||||||
|
* @param obj object to be validated
|
||||||
|
* @return <tt>true</tt>
|
||||||
|
*/
|
||||||
|
public boolean validateObject(Connection<T> obj) {
|
||||||
|
return obj.isOpen();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* activate the object
|
||||||
|
*
|
||||||
|
* @param obj ignored
|
||||||
|
*/
|
||||||
|
public void activateObject(Connection<T> obj) throws Exception {
|
||||||
|
obj.isOpen();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class PooledConnection implements Connection<T> {
|
||||||
|
|
||||||
|
private Connection<T> connection;
|
||||||
|
|
||||||
|
public PooledConnection(Connection<T> con) {
|
||||||
|
this.connection = con;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)l
|
||||||
|
* @see org.springframework.integration.splunk.core.IService#close()
|
||||||
|
*/
|
||||||
|
public void close() {
|
||||||
|
try {
|
||||||
|
pool.returnObject(connection);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("failed to return pooled object", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.IService#isOpen()
|
||||||
|
*/
|
||||||
|
public boolean isOpen() {
|
||||||
|
return connection.isOpen();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.IService#getService()
|
||||||
|
*/
|
||||||
|
public T getTarget() {
|
||||||
|
return connection.getTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.support;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search mode supported by Splunk.
|
||||||
|
*
|
||||||
|
* Blocking: Run synchronous search API
|
||||||
|
* Normal: Run asynchronous search API
|
||||||
|
* Realtime: Run the searches which are over a defined real time window
|
||||||
|
* Export: Run synchronously in your code , best way for bulk exports of events from Splunk
|
||||||
|
* Saved: Run predefined searches/parameters that are saved in Splunk in a namespace and you can execute them by name
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum SearchMode {
|
||||||
|
blocking, normal, realtime, export, saved;
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.support;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.integration.splunk.core.Connection;
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkServer;
|
||||||
|
|
||||||
|
import com.splunk.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connection to Splunk service
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkConnection implements Connection<Service> {
|
||||||
|
|
||||||
|
private Service service;
|
||||||
|
|
||||||
|
public SplunkConnection(SplunkServer splunkServer) {
|
||||||
|
Map<String, Object> args = new HashMap<String, Object>();
|
||||||
|
if (splunkServer.getHost() != null) {
|
||||||
|
args.put("host", splunkServer.getHost());
|
||||||
|
}
|
||||||
|
if (splunkServer.getPort() != 0) {
|
||||||
|
args.put("port", splunkServer.getPort());
|
||||||
|
}
|
||||||
|
if (splunkServer.getScheme() != null) {
|
||||||
|
args.put("scheme", splunkServer.getScheme());
|
||||||
|
}
|
||||||
|
if (splunkServer.getApp() != null) {
|
||||||
|
args.put("app", splunkServer.getApp());
|
||||||
|
}
|
||||||
|
if (splunkServer.getOwner() != null) {
|
||||||
|
args.put("owner", splunkServer.getOwner());
|
||||||
|
}
|
||||||
|
|
||||||
|
args.put("username", splunkServer.getUserName());
|
||||||
|
args.put("password", splunkServer.getPassword());
|
||||||
|
service = Service.connect(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.IService#close()
|
||||||
|
*/
|
||||||
|
public void close() {
|
||||||
|
service.logout();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.IService#isOpen()
|
||||||
|
*/
|
||||||
|
public boolean isOpen() {
|
||||||
|
boolean result = true;
|
||||||
|
try {
|
||||||
|
service.getApplications();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.IService#getService()
|
||||||
|
*/
|
||||||
|
public Service getTarget() {
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.support;
|
||||||
|
|
||||||
|
import org.springframework.integration.splunk.core.Connection;
|
||||||
|
import org.springframework.integration.splunk.core.ConnectionFactory;
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkServer;
|
||||||
|
|
||||||
|
import com.splunk.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory to create Splunk connection.
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkConnectionFactory implements ConnectionFactory<Service> {
|
||||||
|
|
||||||
|
private SplunkServer splunkServer;
|
||||||
|
|
||||||
|
public SplunkConnectionFactory(SplunkServer server) {
|
||||||
|
this.splunkServer = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.ServiceFactory#getService()
|
||||||
|
*/
|
||||||
|
public Connection<Service> getConnection() throws Exception {
|
||||||
|
return new SplunkConnection(splunkServer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,470 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.support;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.integration.splunk.core.Connection;
|
||||||
|
import org.springframework.integration.splunk.core.ConnectionFactory;
|
||||||
|
import org.springframework.integration.splunk.core.DataReader;
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkData;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import com.splunk.Args;
|
||||||
|
import com.splunk.Job;
|
||||||
|
import com.splunk.ResultsReader;
|
||||||
|
import com.splunk.ResultsReaderXml;
|
||||||
|
import com.splunk.SavedSearch;
|
||||||
|
import com.splunk.SavedSearchCollection;
|
||||||
|
import com.splunk.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data reader to search data from Splunk.
|
||||||
|
*
|
||||||
|
* There are 5 ways to search data provided by Splunk SDK: saved search, blocking search,
|
||||||
|
* non blocking search, realtime search, export search.
|
||||||
|
*
|
||||||
|
* Splunk search also supports time range search with earliestTime and latestTime.
|
||||||
|
* For the first time start, initEarliestTime is used as earliestTime.
|
||||||
|
* If user does not specify earliestTime and latestTime, latestTime is "now"
|
||||||
|
* earliestTime is the time that last polling is run.
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkDataReader implements DataReader, InitializingBean {
|
||||||
|
|
||||||
|
private static final String DATE_FORMAT = "MM/dd/yy HH:mm:ss:SSS";
|
||||||
|
|
||||||
|
private static final String SPLUNK_TIME_FORMAT = "%m/%d/%y %H:%M:%S:%3N";
|
||||||
|
|
||||||
|
private static final Log logger = LogFactory.getLog(SplunkDataReader.class);
|
||||||
|
|
||||||
|
private ConnectionFactory<Service> connectionFactory;
|
||||||
|
|
||||||
|
private SearchMode mode;
|
||||||
|
|
||||||
|
private int count = 0;
|
||||||
|
|
||||||
|
private String fieldList;
|
||||||
|
|
||||||
|
private String search;
|
||||||
|
|
||||||
|
private String earliestTime;
|
||||||
|
|
||||||
|
private String latestTime;
|
||||||
|
|
||||||
|
private String savedSearch;
|
||||||
|
|
||||||
|
private String owner;
|
||||||
|
|
||||||
|
private String app;
|
||||||
|
|
||||||
|
private String initEarliestTime;
|
||||||
|
|
||||||
|
private transient Calendar lastSuccessfulReadTime;
|
||||||
|
|
||||||
|
public SplunkDataReader(ConnectionFactory<Service> f) {
|
||||||
|
this.connectionFactory = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearch(String searchStr) {
|
||||||
|
Assert.hasText(searchStr, "search must be neither null nor empty");
|
||||||
|
this.search = searchStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEarliestTime(String earliestTime) {
|
||||||
|
this.earliestTime = earliestTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLatestTime(String latestTime) {
|
||||||
|
this.latestTime = latestTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSavedSearch(String savedSearch) {
|
||||||
|
this.savedSearch = savedSearch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMode(SearchMode mode) {
|
||||||
|
Assert.notNull(mode, "mode must be set");
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCount(int count) {
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldList(String fieldList) {
|
||||||
|
this.fieldList = fieldList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOwner(String owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApp(String app) {
|
||||||
|
this.app = app;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInitEarliestTime(String initEarliestTime) {
|
||||||
|
Assert.notNull(initEarliestTime, "initial earliest time can not be null");
|
||||||
|
this.initEarliestTime = initEarliestTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SearchMode getMode() {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFieldList() {
|
||||||
|
return fieldList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSearch() {
|
||||||
|
return search;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEarliestTime() {
|
||||||
|
return earliestTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLatestTime() {
|
||||||
|
return latestTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSavedSearch() {
|
||||||
|
return savedSearch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInitEarliestTime() {
|
||||||
|
return initEarliestTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApp() {
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SplunkData> search() throws Exception {
|
||||||
|
logger.debug("mode:" + mode);
|
||||||
|
switch (mode) {
|
||||||
|
case saved: {
|
||||||
|
return savedSearch();
|
||||||
|
}
|
||||||
|
case blocking: {
|
||||||
|
return blockingSearch();
|
||||||
|
}
|
||||||
|
case normal: {
|
||||||
|
return nonBlockingSearch();
|
||||||
|
}
|
||||||
|
case export: {
|
||||||
|
return exportSearch();
|
||||||
|
}
|
||||||
|
case realtime: {
|
||||||
|
return realtimeSearch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the earliestTime of range search.
|
||||||
|
*
|
||||||
|
* @param startTime the time where search start
|
||||||
|
* @param realtime if this is realtime search
|
||||||
|
*
|
||||||
|
* @return The time of last successful read if not realtime;
|
||||||
|
* Time difference between last successful read and start time;
|
||||||
|
*/
|
||||||
|
private String calculateEarliestTime(Calendar startTime, boolean realtime) {
|
||||||
|
String result = null;
|
||||||
|
if (realtime) {
|
||||||
|
result = calculateEarliestTimeForRealTime(startTime);
|
||||||
|
}
|
||||||
|
DateFormat df = new SimpleDateFormat(DATE_FORMAT);
|
||||||
|
result = df.format(lastSuccessfulReadTime.getTime());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get earliest time for realtime search
|
||||||
|
*
|
||||||
|
* @param startTime
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String calculateEarliestTimeForRealTime(Calendar startTime) {
|
||||||
|
String result = null;
|
||||||
|
long diff = startTime.getTimeInMillis() - lastSuccessfulReadTime.getTimeInMillis();
|
||||||
|
result = "-" + diff / 1000 + "s";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateArgs(Args queryArgs, Calendar startTime, boolean realtime) {
|
||||||
|
String earliestTime = getEarliestTime(startTime, realtime);
|
||||||
|
if (StringUtils.hasText(earliestTime)) {
|
||||||
|
queryArgs.put("earliest_time", earliestTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
String latestTime = getLatestTime(startTime, realtime);
|
||||||
|
if (StringUtils.hasText(latestTime)) {
|
||||||
|
queryArgs.put("latest_time", latestTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
queryArgs.put("time_format", SPLUNK_TIME_FORMAT);
|
||||||
|
|
||||||
|
if (StringUtils.hasText(fieldList)) {
|
||||||
|
queryArgs.put("field_list", fieldList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getLatestTime(Calendar startTime, boolean realtime) {
|
||||||
|
String lTime = null;
|
||||||
|
if (StringUtils.hasText(latestTime)) {
|
||||||
|
lTime = latestTime;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (realtime) {
|
||||||
|
lTime = "rt";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DateFormat df = new SimpleDateFormat(DATE_FORMAT);
|
||||||
|
lTime = df.format(startTime.getTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getEarliestTime(Calendar startTime, boolean realtime) {
|
||||||
|
String eTime = null;
|
||||||
|
|
||||||
|
if (lastSuccessfulReadTime == null) {
|
||||||
|
eTime = initEarliestTime;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (StringUtils.hasText(earliestTime)) {
|
||||||
|
eTime = earliestTime;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
String calculatedEarliestTime = calculateEarliestTime(startTime, realtime);
|
||||||
|
if (calculatedEarliestTime != null) {
|
||||||
|
if (realtime) {
|
||||||
|
eTime = "rt" + calculatedEarliestTime;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
eTime = calculatedEarliestTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return eTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<SplunkData> runQuery(Args queryArgs) throws Exception {
|
||||||
|
Connection<Service> connection = connectionFactory.getConnection();
|
||||||
|
try {
|
||||||
|
Job job = connection.getTarget().getJobs().create(search, queryArgs);
|
||||||
|
while (!job.isDone()) {
|
||||||
|
Thread.sleep(2000);
|
||||||
|
}
|
||||||
|
return extractData(job);
|
||||||
|
} finally {
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SplunkData> blockingSearch() throws Exception {
|
||||||
|
logger.debug("block search start");
|
||||||
|
|
||||||
|
Args queryArgs = new Args();
|
||||||
|
queryArgs.put("exec_mode", "blocking");
|
||||||
|
Calendar startTime = Calendar.getInstance();
|
||||||
|
populateArgs(queryArgs, startTime, false);
|
||||||
|
List<SplunkData> data = runQuery(queryArgs);
|
||||||
|
lastSuccessfulReadTime = startTime;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<SplunkData> nonBlockingSearch() throws Exception {
|
||||||
|
logger.debug("non block search start");
|
||||||
|
|
||||||
|
Args queryArgs = new Args();
|
||||||
|
queryArgs.put("exec_mode", "normal");
|
||||||
|
Calendar startTime = Calendar.getInstance();
|
||||||
|
populateArgs(queryArgs, startTime, false);
|
||||||
|
|
||||||
|
List<SplunkData> data = runQuery(queryArgs);
|
||||||
|
lastSuccessfulReadTime = startTime;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private List<SplunkData> realtimeSearch() throws Exception {
|
||||||
|
logger.debug("realtime search start");
|
||||||
|
|
||||||
|
Args queryArgs = new Args();
|
||||||
|
queryArgs.put("search_mode", "realtime");
|
||||||
|
Calendar startTime = Calendar.getInstance();
|
||||||
|
populateArgs(queryArgs, startTime, true);
|
||||||
|
|
||||||
|
List<SplunkData> data = runQuery(queryArgs);
|
||||||
|
lastSuccessfulReadTime = startTime;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private List<SplunkData> exportSearch() throws Exception {
|
||||||
|
logger.debug("export start");
|
||||||
|
List<SplunkData> result = new ArrayList<SplunkData>();
|
||||||
|
HashMap<String, String> data;
|
||||||
|
SplunkData splunkData;
|
||||||
|
|
||||||
|
Args queryArgs = new Args();
|
||||||
|
Calendar startTime = Calendar.getInstance();
|
||||||
|
populateArgs(queryArgs, startTime, false);
|
||||||
|
queryArgs.put("output_mode", "xml");
|
||||||
|
|
||||||
|
Connection<Service> connection = connectionFactory.getConnection();
|
||||||
|
try {
|
||||||
|
InputStream os = connection.getTarget().export(search, queryArgs);
|
||||||
|
ResultsReaderXml resultsReader = new ResultsReaderXml(os);
|
||||||
|
while ((data = resultsReader.getNextEvent()) != null) {
|
||||||
|
splunkData = new SplunkData(data);
|
||||||
|
result.add(splunkData);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} finally {
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<SplunkData> savedSearch() throws Exception {
|
||||||
|
logger.debug("saved search start");
|
||||||
|
|
||||||
|
Args queryArgs = new Args();
|
||||||
|
queryArgs.put("app", "search");
|
||||||
|
if (owner != null && owner.length() > 0) {
|
||||||
|
queryArgs.put("owner", owner);
|
||||||
|
}
|
||||||
|
if (app != null && app.length() > 0) {
|
||||||
|
queryArgs.put("app", app);
|
||||||
|
}
|
||||||
|
|
||||||
|
Calendar startTime = Calendar.getInstance();
|
||||||
|
Connection<Service> connection = connectionFactory.getConnection();
|
||||||
|
try {
|
||||||
|
SavedSearch search = null;
|
||||||
|
Job job = null;
|
||||||
|
String latestTime = getLatestTime(startTime, false);
|
||||||
|
String earliestTime = getEarliestTime(startTime, false);
|
||||||
|
SavedSearchCollection savedSearches = connection.getTarget().getSavedSearches(queryArgs);
|
||||||
|
for (SavedSearch s : savedSearches.values()) {
|
||||||
|
if (s.getName().equals(savedSearch)) {
|
||||||
|
search = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (search != null) {
|
||||||
|
Map<String, String> args = new HashMap<String, String>();
|
||||||
|
args.put("force_dispatch", "true");
|
||||||
|
args.put("dispatch.earliest_time", earliestTime);
|
||||||
|
args.put("dispatch.latest_time", latestTime);
|
||||||
|
job = search.dispatch(args);
|
||||||
|
}
|
||||||
|
while (!job.isDone()) {
|
||||||
|
Thread.sleep(2000);
|
||||||
|
}
|
||||||
|
List<SplunkData> data = extractData(job);
|
||||||
|
this.lastSuccessfulReadTime = startTime;
|
||||||
|
return data;
|
||||||
|
} finally {
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SplunkData> extractData(Job job) throws Exception {
|
||||||
|
List<SplunkData> result = new ArrayList<SplunkData>();
|
||||||
|
HashMap<String, String> data;
|
||||||
|
SplunkData splunkData;
|
||||||
|
ResultsReader resultsReader;
|
||||||
|
int total = job.getResultCount();
|
||||||
|
|
||||||
|
if (count == 0 || total < count) {
|
||||||
|
InputStream stream = null;
|
||||||
|
Args outputArgs = new Args();
|
||||||
|
outputArgs.put("output_mode", "xml");
|
||||||
|
stream = job.getResults(outputArgs);
|
||||||
|
|
||||||
|
resultsReader = new ResultsReaderXml(stream);
|
||||||
|
while ((data = resultsReader.getNextEvent()) != null) {
|
||||||
|
splunkData = new SplunkData(data);
|
||||||
|
result.add(splunkData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int offset = 0;
|
||||||
|
while (offset < total) {
|
||||||
|
InputStream stream = null;
|
||||||
|
Args outputArgs = new Args();
|
||||||
|
outputArgs.put("output_mode", "xml");
|
||||||
|
outputArgs.put("count", count);
|
||||||
|
outputArgs.put("offset", offset);
|
||||||
|
stream = job.getResults(outputArgs);
|
||||||
|
resultsReader = new ResultsReaderXml(stream);
|
||||||
|
while ((data = resultsReader.getNextEvent()) != null) {
|
||||||
|
splunkData = new SplunkData(data);
|
||||||
|
result.add(splunkData);
|
||||||
|
}
|
||||||
|
offset += count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
Assert.notNull(initEarliestTime, "initial earliest time can not be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,202 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.support;
|
||||||
|
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.net.Socket;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.integration.splunk.core.Connection;
|
||||||
|
import org.springframework.integration.splunk.core.DataWriter;
|
||||||
|
import org.springframework.integration.splunk.core.ConnectionFactory;
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkData;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
import com.splunk.Args;
|
||||||
|
import com.splunk.Index;
|
||||||
|
import com.splunk.Receiver;
|
||||||
|
import com.splunk.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data writer to write data into Splunk. There are 3 ways to write data:
|
||||||
|
* REST submit, TCP socket and HTTP stream.
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkDataWriter implements DataWriter, InitializingBean {
|
||||||
|
|
||||||
|
private static final Log logger = LogFactory.getLog(SplunkDataWriter.class);
|
||||||
|
|
||||||
|
private ConnectionFactory<Service> connectionFactory;
|
||||||
|
|
||||||
|
private String sourceType;
|
||||||
|
|
||||||
|
private String source;
|
||||||
|
|
||||||
|
private String index;
|
||||||
|
|
||||||
|
private IngestType ingest = IngestType.stream; //tcp, stream, submit
|
||||||
|
|
||||||
|
private int tcpPort;
|
||||||
|
|
||||||
|
private String host;
|
||||||
|
|
||||||
|
private String hostRegex;
|
||||||
|
|
||||||
|
public SplunkDataWriter(ConnectionFactory<Service> f) {
|
||||||
|
this.connectionFactory = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(SplunkData data) throws Exception {
|
||||||
|
logger.debug("write message to splunk:" + data);
|
||||||
|
|
||||||
|
Connection<Service> connection = connectionFactory.getConnection();
|
||||||
|
Service service = connection.getTarget();
|
||||||
|
Index indexObject = null;
|
||||||
|
Receiver receiver = null;
|
||||||
|
OutputStream ostream;
|
||||||
|
Socket socket;
|
||||||
|
Writer writer = null;
|
||||||
|
|
||||||
|
Args args = new Args();
|
||||||
|
if (sourceType != null) {
|
||||||
|
args.put("sourcetype", sourceType);
|
||||||
|
}
|
||||||
|
if (source != null) {
|
||||||
|
args.put("source", source);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (host != null) {
|
||||||
|
args.put("host", host);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hostRegex != null) {
|
||||||
|
args.put("host_regex", hostRegex);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (index != null) {
|
||||||
|
indexObject = service.getIndexes().get(index);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
receiver = service.getReceiver();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ingest.equals(IngestType.stream) || ingest.equals(IngestType.tcp))) {
|
||||||
|
if (ingest.equals("stream")) {
|
||||||
|
if (indexObject != null)
|
||||||
|
socket = indexObject.attach(args);
|
||||||
|
else
|
||||||
|
socket = receiver.attach(args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
socket = service.open(tcpPort);
|
||||||
|
}
|
||||||
|
ostream = socket.getOutputStream();
|
||||||
|
writer = new OutputStreamWriter(ostream, "UTF8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ingest.equals(IngestType.stream) || ingest.equals(IngestType.tcp))) {
|
||||||
|
writer.write(data.toString());
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (index != null) {
|
||||||
|
indexObject.submit(args, data.toString());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
receiver.submit(args, data.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setSourceType(String sourceType) {
|
||||||
|
this.sourceType = sourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSource(String source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndex(String index) {
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIngest(IngestType ingest) {
|
||||||
|
this.ingest = ingest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTcpPort(int tcpPort) {
|
||||||
|
this.tcpPort = tcpPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHost(String host) {
|
||||||
|
this.host = host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHostRegex(String hostRegex) {
|
||||||
|
this.hostRegex = hostRegex;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getSourceType() {
|
||||||
|
return sourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IngestType getIngest() {
|
||||||
|
return ingest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTcpPort() {
|
||||||
|
return tcpPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHost() {
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHostRegex() {
|
||||||
|
return hostRegex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||||
|
*/
|
||||||
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
Assert.notNull(ingest, "You must specify ingest type");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.support;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.integration.Message;
|
||||||
|
import org.springframework.integration.MessageHandlingException;
|
||||||
|
import org.springframework.integration.MessagingException;
|
||||||
|
import org.springframework.integration.splunk.core.DataReader;
|
||||||
|
import org.springframework.integration.splunk.core.DataWriter;
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bundles common core logic for the Splunk components.
|
||||||
|
*
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkExecutor implements InitializingBean {
|
||||||
|
|
||||||
|
private static final Log logger = LogFactory.getLog(SplunkExecutor.class);
|
||||||
|
|
||||||
|
private DataReader reader;
|
||||||
|
private DataWriter writer;
|
||||||
|
|
||||||
|
public SplunkExecutor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies and sets the parameters. E.g. initializes the to be used
|
||||||
|
*/
|
||||||
|
public void afterPropertiesSet() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the outbound Splunk Operation.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public Object executeOutboundOperation(final Message<?> message) {
|
||||||
|
try {
|
||||||
|
SplunkData payload = (SplunkData) message.getPayload();
|
||||||
|
writer.write(payload);
|
||||||
|
} catch (Exception e) {
|
||||||
|
String errorMsg = "error in writing data into Splunk";
|
||||||
|
logger.warn(errorMsg, e);
|
||||||
|
throw new MessageHandlingException(message, errorMsg, e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleMessage(final Message<?> message) {
|
||||||
|
executeOutboundOperation(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the Splunk operation.
|
||||||
|
*/
|
||||||
|
public List<SplunkData> poll() {
|
||||||
|
logger.debug("poll start:");
|
||||||
|
List<SplunkData> queryData = null;
|
||||||
|
try {
|
||||||
|
queryData = reader.search();
|
||||||
|
} catch (Exception e) {
|
||||||
|
String errorMsg = "search Splunk data failed";
|
||||||
|
logger.warn(errorMsg, e);
|
||||||
|
throw new MessagingException(errorMsg, e);
|
||||||
|
}
|
||||||
|
return queryData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReader(DataReader reader) {
|
||||||
|
this.reader = reader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWriter(DataWriter writer) {
|
||||||
|
this.writer = writer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
1
src/main/resources/META-INF/spring.handlers
Normal file
1
src/main/resources/META-INF/spring.handlers
Normal file
@@ -0,0 +1 @@
|
|||||||
|
http\://www.springframework.org/schema/integration/splunk=org.springframework.integration.splunk.config.xml.SplunkNamespaceHandler
|
||||||
2
src/main/resources/META-INF/spring.schemas
Normal file
2
src/main/resources/META-INF/spring.schemas
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
http\://www.springframework.org/schema/integration/splunk/spring-integration-splunk-1.0.xsd=org/springframework/integration/splunk/config/xml/spring-integration-splunk-1.0.xsd
|
||||||
|
http\://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd=org/springframework/integration/splunk/config/xml/spring-integration-splunk-1.0.xsd
|
||||||
4
src/main/resources/META-INF/spring.tooling
Normal file
4
src/main/resources/META-INF/spring.tooling
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Tooling related information for the integration Splunk namespace
|
||||||
|
http\://www.springframework.org/schema/integration/splunk@name=integration Splunk Namespace
|
||||||
|
http\://www.springframework.org/schema/integration/splunk@prefix=int-splunk
|
||||||
|
http\://www.springframework.org/schema/integration/splunk@icon=org/springframework/integration/splunk/config/xml/spring-integration-splunk.gif
|
||||||
@@ -0,0 +1,364 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<xsd:schema xmlns="http://www.springframework.org/schema/integration/splunk"
|
||||||
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:beans="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:tool="http://www.springframework.org/schema/tool"
|
||||||
|
xmlns:integration="http://www.springframework.org/schema/integration"
|
||||||
|
targetNamespace="http://www.springframework.org/schema/integration/splunk"
|
||||||
|
elementFormDefault="qualified" attributeFormDefault="unqualified">
|
||||||
|
|
||||||
|
<xsd:import namespace="http://www.springframework.org/schema/beans" />
|
||||||
|
<xsd:import namespace="http://www.springframework.org/schema/tool" />
|
||||||
|
<xsd:import namespace="http://www.springframework.org/schema/integration"
|
||||||
|
schemaLocation="http://www.springframework.org/schema/integration/spring-integration-2.2.xsd" />
|
||||||
|
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation><![CDATA[
|
||||||
|
Defines the configuration elements for the Spring Integration
|
||||||
|
Splunk Adapter.
|
||||||
|
]]></xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
|
||||||
|
<xsd:element name="server">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation><![CDATA[
|
||||||
|
Defines a Splunk server information.
|
||||||
|
]]></xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="host" use="optional">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation><![CDATA[
|
||||||
|
Indicates the Splunk server name or IP address
|
||||||
|
]]></xsd:documentation>
|
||||||
|
<xsd:appinfo>
|
||||||
|
<tool:annotation kind="direct">
|
||||||
|
<tool:expected-type type="java.lang.String" />
|
||||||
|
</tool:annotation>
|
||||||
|
</xsd:appinfo>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="port" use="optional">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation><![CDATA[
|
||||||
|
Indicates the Splunk server port
|
||||||
|
]]></xsd:documentation>
|
||||||
|
<xsd:appinfo>
|
||||||
|
<tool:annotation kind="direct">
|
||||||
|
<tool:expected-type type="java.lang.Integer" />
|
||||||
|
</tool:annotation>
|
||||||
|
</xsd:appinfo>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="scheme" use="optional">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation><![CDATA[
|
||||||
|
Indicates the Splunk server scheme
|
||||||
|
]]></xsd:documentation>
|
||||||
|
<xsd:appinfo>
|
||||||
|
<tool:annotation kind="direct">
|
||||||
|
<tool:expected-type type="java.lang.String" />
|
||||||
|
</tool:annotation>
|
||||||
|
</xsd:appinfo>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="app" use="optional">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation><![CDATA[
|
||||||
|
Indicates the Splunk server application name
|
||||||
|
]]></xsd:documentation>
|
||||||
|
<xsd:appinfo>
|
||||||
|
<tool:annotation kind="direct">
|
||||||
|
<tool:expected-type type="java.lang.String" />
|
||||||
|
</tool:annotation>
|
||||||
|
</xsd:appinfo>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="owner" use="optional">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation><![CDATA[
|
||||||
|
Indicates the Splunk server owner name
|
||||||
|
]]></xsd:documentation>
|
||||||
|
<xsd:appinfo>
|
||||||
|
<tool:annotation kind="direct">
|
||||||
|
<tool:expected-type type="java.lang.String" />
|
||||||
|
</tool:annotation>
|
||||||
|
</xsd:appinfo>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="userName" use="required">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation><![CDATA[
|
||||||
|
Indicates the userName to login Splunk server
|
||||||
|
]]></xsd:documentation>
|
||||||
|
<xsd:appinfo>
|
||||||
|
<tool:annotation kind="direct">
|
||||||
|
<tool:expected-type type="java.lang.String" />
|
||||||
|
</tool:annotation>
|
||||||
|
</xsd:appinfo>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="password" use="required">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation><![CDATA[
|
||||||
|
Indicates the password to login Splunk server
|
||||||
|
]]></xsd:documentation>
|
||||||
|
<xsd:appinfo>
|
||||||
|
<tool:annotation kind="direct">
|
||||||
|
<tool:expected-type type="java.lang.String" />
|
||||||
|
</tool:annotation>
|
||||||
|
</xsd:appinfo>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="scope" type="xsd:string" use="optional" />
|
||||||
|
<xsd:attribute name="id" type="xsd:ID" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
|
||||||
|
<xsd:element name="inbound-channel-adapter">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
The definition for the Spring Integration Splunk
|
||||||
|
Inbound Channel Adapter.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element ref="integration:poller" minOccurs="0"
|
||||||
|
maxOccurs="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attributeGroup ref="coreSplunkComponentAttributes" />
|
||||||
|
<xsd:attribute name="channel" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:appinfo>
|
||||||
|
<tool:annotation kind="ref">
|
||||||
|
<tool:expected-type
|
||||||
|
type="org.springframework.integration.core.MessageChannel" />
|
||||||
|
</tool:annotation>
|
||||||
|
</xsd:appinfo>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="send-timeout" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation><![CDATA[
|
||||||
|
Allows you to specify how long this inbound-channel-adapter
|
||||||
|
will wait for the message (containing the retrieved entities)
|
||||||
|
to be sent successfully to the message channel, before throwing
|
||||||
|
an exception.
|
||||||
|
|
||||||
|
Keep in mind that when sending to a DirectChannel, the
|
||||||
|
invocation will occur in the sender's thread so the failing
|
||||||
|
of the send operation may be caused by other components
|
||||||
|
further downstream. By default the Inbound Channel Adapter
|
||||||
|
will wait indefinitely. The value is specified in milliseconds.
|
||||||
|
]]>
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="mode" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Search mode: normal, blocking, realtime, export, saved
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="count" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
The maximum number of event record to be return
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="fieldList" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
A comma-separated list of the fields to return
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="search" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Search String following Splunk syntax.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="earliestTime" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Time modifier for the start of the time window.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="latestTime" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Time modifier for the end of the time window.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="initEarliestTime" type="xsd:string" use="required">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Time modifier for the start of the time window for the first search.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="savedSearch" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Saved search.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="owner" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Owner of the saved search.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="app" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
App of the saved search.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
|
||||||
|
<xsd:element name="outbound-channel-adapter">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Defines an outbound Channel Adapter.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element ref="integration:poller" minOccurs="0"
|
||||||
|
maxOccurs="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attributeGroup ref="coreSplunkComponentAttributes" />
|
||||||
|
<xsd:attribute name="channel" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:appinfo>
|
||||||
|
<xsd:documentation>
|
||||||
|
Channel from which messages will be output.
|
||||||
|
When a message is sent to this channel it will
|
||||||
|
cause the query
|
||||||
|
to
|
||||||
|
be executed.
|
||||||
|
</xsd:documentation>
|
||||||
|
<tool:annotation kind="ref">
|
||||||
|
<tool:expected-type
|
||||||
|
type="org.springframework.integration.MessageChannel" />
|
||||||
|
</tool:annotation>
|
||||||
|
</xsd:appinfo>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="order">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Specifies the order for invocation when this
|
||||||
|
endpoint is connected as a
|
||||||
|
subscriber to a SubscribableChannel.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="source" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Splunk event source
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="sourceType" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Splunk event source type
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="index" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Splunk index name
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="ingest" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Splunk ingest method: tcp, streaming, submit. Default stream.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="tcpPort" type="xsd:integer">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Splunk ingest method: tcp, streaming, submit. Default stream.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="host" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Host where the event occurred
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="hostRegex" type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Host regex can be provided so Splunk can dynamically extract the host value from the log event
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
|
||||||
|
<xsd:attributeGroup name="coreSplunkComponentAttributes">
|
||||||
|
<xsd:attribute name="id" type="xsd:string" use="optional">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Identifies the underlying Spring bean definition,
|
||||||
|
which is an
|
||||||
|
instance of either 'EventDrivenConsumer' or
|
||||||
|
'PollingConsumer',
|
||||||
|
depending on whether the component's input
|
||||||
|
channel is a
|
||||||
|
'SubscribableChannel' or 'PollableChannel'.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="auto-startup" default="true" use="optional">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Flag to indicate that the component should start
|
||||||
|
automatically
|
||||||
|
on startup (default true).
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
<xsd:simpleType>
|
||||||
|
<xsd:union memberTypes="xsd:boolean xsd:string" />
|
||||||
|
</xsd:simpleType>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="splunk-server-ref" use="required"
|
||||||
|
type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Splunk Server Bean Name
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
<xsd:attribute name="pool-server-connection" use="optional" default="true"
|
||||||
|
type="xsd:string">
|
||||||
|
<xsd:annotation>
|
||||||
|
<xsd:documentation>
|
||||||
|
Whether pool the Splunk connection.
|
||||||
|
</xsd:documentation>
|
||||||
|
</xsd:annotation>
|
||||||
|
</xsd:attribute>
|
||||||
|
</xsd:attributeGroup>
|
||||||
|
|
||||||
|
</xsd:schema>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 572 B |
20
src/reference/docbook/history.xml
Normal file
20
src/reference/docbook/history.xml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<appendix xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="history"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||||
|
<title>Change History</title>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<td>Release</td>
|
||||||
|
<td>Date</td>
|
||||||
|
<td>Changes</td>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>0.5.0</td>
|
||||||
|
<td>2012.9.28</td>
|
||||||
|
<td>Initial release</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</appendix>
|
||||||
BIN
src/reference/docbook/images/logo.png
Normal file
BIN
src/reference/docbook/images/logo.png
Normal file
Binary file not shown.
64
src/reference/docbook/index.xml
Normal file
64
src/reference/docbook/index.xml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<book xmlns="http://docbook.org/ns/docbook" version="5.0"
|
||||||
|
xml:id="spring-integration-reference" xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<bookinfo>
|
||||||
|
<title>Spring Integration Splunk Adapter</title>
|
||||||
|
<titleabbrev>Splunk Adapter ${version}</titleabbrev>
|
||||||
|
<productname>Spring Integration</productname>
|
||||||
|
<releaseinfo>${version}</releaseinfo>
|
||||||
|
|
||||||
|
<!-- TODO: this isn't showing up. -->
|
||||||
|
<mediaobject>
|
||||||
|
<imageobject role="fo">
|
||||||
|
<imagedata fileref="images/logo.png" format="PNG" align="center" />
|
||||||
|
</imageobject>
|
||||||
|
<imageobject role="html">
|
||||||
|
<imagedata fileref="images/logo.png" format="PNG" align="center" />
|
||||||
|
</imageobject>
|
||||||
|
</mediaobject>
|
||||||
|
<!-- END TODO -->
|
||||||
|
|
||||||
|
<authorgroup>
|
||||||
|
<author><firstname>Jarred Li</firstname></author>
|
||||||
|
<author><firstname>Mark Pollack</firstname></author>
|
||||||
|
<author><firstname>Damien Dallimore</firstname></author>
|
||||||
|
</authorgroup>
|
||||||
|
<legalnotice>
|
||||||
|
<para>© SpringSource Inc., 2012</para>
|
||||||
|
</legalnotice>
|
||||||
|
</bookinfo>
|
||||||
|
|
||||||
|
<toc></toc>
|
||||||
|
|
||||||
|
<part id="whats-new-part">
|
||||||
|
<title>What's new?</title>
|
||||||
|
<partintro id="spring-integration-intro">
|
||||||
|
<para>
|
||||||
|
If you are interested in the changes and features, that were introduced in
|
||||||
|
earlier versions, please take a look at chapter:
|
||||||
|
|
||||||
|
<xref linkend="history" />
|
||||||
|
|
||||||
|
</para>
|
||||||
|
</partintro>
|
||||||
|
<xi:include href="./whats-new.xml" />
|
||||||
|
</part>
|
||||||
|
|
||||||
|
<part id="spring-integration-adapters">
|
||||||
|
<title>Integration Adapters</title>
|
||||||
|
<partintro id="spring-integration-adapters">
|
||||||
|
<para>
|
||||||
|
Spring Integration adapter for Splunk includes inbound channel adapter to
|
||||||
|
read data from Splunk and outbound channel adapter to write data into
|
||||||
|
Splunk.
|
||||||
|
</para>
|
||||||
|
</partintro>
|
||||||
|
<xi:include href="./splunk.xml" />
|
||||||
|
</part>
|
||||||
|
<part id="spring-integration-appendices">
|
||||||
|
<title>Appendices</title>
|
||||||
|
<xi:include href="./resources.xml" />
|
||||||
|
<xi:include href="./history.xml" />
|
||||||
|
</part>
|
||||||
|
</book>
|
||||||
27
src/reference/docbook/resources.xml
Normal file
27
src/reference/docbook/resources.xml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<appendix xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="resources"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<title>Additional Resources</title>
|
||||||
|
|
||||||
|
<section id="spring-integration-home">
|
||||||
|
<title>Spring Integration Home</title>
|
||||||
|
<para>
|
||||||
|
The definitive source of information about Spring Integration is the
|
||||||
|
<ulink url="http://www.springsource.org/spring-integration">Spring Integration Home</ulink> at
|
||||||
|
<ulink url="http://www.springsource.org">http://www.springsource.org</ulink>. That site serves as a hub of
|
||||||
|
information and is the best place to find up-to-date announcements about the project as well as links to
|
||||||
|
articles, blogs, and new sample applications.
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="splunk-home">
|
||||||
|
<title>Splunk Home</title>
|
||||||
|
<para>
|
||||||
|
You can get more information on Splunk from <ulink url="http://www.splunk.com">Splunk Home</ulink>.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Splunk SDK API is in <ulink url="http://dev.splunk.com/">Splunk Dev</ulink>.
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</appendix>
|
||||||
218
src/reference/docbook/splunk.xml
Normal file
218
src/reference/docbook/splunk.xml
Normal file
@@ -0,0 +1,218 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<chapter xmlns="http://docbook.org/ns/docbook" version="5.0"
|
||||||
|
xml:id="splunk" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<title>Splunk Adapter</title>
|
||||||
|
<para>
|
||||||
|
The Spring Integration Splunk Adapter provides outbound and inbound channel adapters:
|
||||||
|
</para>
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<emphasis>
|
||||||
|
<link linkend='splunk-outbound-channel-adapter'>Outbound Channel adapter</link>
|
||||||
|
</emphasis>
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<emphasis>
|
||||||
|
<link linkend='splunk-inbound-channel-adapter'>Inbound Channel Adapter</link>
|
||||||
|
</emphasis>
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
To use Spring Integration adapter for Splunk, you have to import the XML namespace. For example, you can
|
||||||
|
have following XML:
|
||||||
|
</para>
|
||||||
|
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:int="http://www.springframework.org/schema/integration"
|
||||||
|
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/integration/splunk
|
||||||
|
http://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||||
|
http://www.springframework.org/schema/integration
|
||||||
|
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||||
|
http://www.springframework.org/schema/beans
|
||||||
|
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||||
|
|
||||||
|
</beans>]]></programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Meanwhile, you have to define your Splunk server information. For example
|
||||||
|
you can define server as following:
|
||||||
|
</para>
|
||||||
|
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/integration/splunk
|
||||||
|
http://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||||
|
http://www.springframework.org/schema/beans
|
||||||
|
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||||
|
...
|
||||||
|
<int-splunk:server id="splunkServer" host="somehost" port="8089"
|
||||||
|
userName="user" password="password" owner="admin"/>
|
||||||
|
...
|
||||||
|
</beans>]]></programlisting>
|
||||||
|
|
||||||
|
<section id="splunk-outbound-channel-adapter">
|
||||||
|
<title>Outbound Channel Adapter</title>
|
||||||
|
<para>
|
||||||
|
Outbound channel adapter is used to put data into Splunk from
|
||||||
|
channels in Spring Integration.
|
||||||
|
There are 3 kinds of method to put data:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>Submit (HTTP REST)</listitem>
|
||||||
|
<listitem>Stream</listitem>
|
||||||
|
<listitem>Tcp</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The main difference between using the REST inputs vs plain TCP/UDP inputs is really
|
||||||
|
in the Splunk event handling pipeline.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
With REST , you have to declare your event meta data (index, source, source type…)
|
||||||
|
in the HTTP request at the source. You can't really transform the log event anymore
|
||||||
|
after you have created and sent it to Splunk.Typically though, for people using REST,
|
||||||
|
this is fine because they are well formatting their log events before sending them
|
||||||
|
anyway ie: no further processing/transforming and manipulation is required.
|
||||||
|
You can however still do dynamic search time transforms/filtering on the
|
||||||
|
data when later searching over it in Splunk.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
To use outbound channel adapter with submit, you can define the adapter as following:
|
||||||
|
</para>
|
||||||
|
<programlisting language="xml"><![CDATA[<int-splunk:outbound-channel-adapter id="splunkOutboundChannelAdapter"
|
||||||
|
auto-startup="true" order="1"
|
||||||
|
channel="outputToSplunk"
|
||||||
|
splunk-server-ref="splunkServer"
|
||||||
|
pool-server-connection="true" sourceType="spring-integration" source="example"
|
||||||
|
ingest="submit">
|
||||||
|
</int-splunk:outbound-channel-adapter>]]></programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
With TCP inputs , you can manipulate and transform the event data in Splunk before
|
||||||
|
it gets indexed (using entrys in props.conf/transforms.conf). The event meta data
|
||||||
|
(index, source, source type…) gets declared on the Splunk side when you establish
|
||||||
|
the TCP/UDP input and can also be dynamically created, so essentially you have
|
||||||
|
a lot more control over the indexing of the event data.This is generally more
|
||||||
|
important when you don't control the format of the data at the source and it needs
|
||||||
|
manipulating/filtering ie: network devices syslogging etc…
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
To use outbound channel adapter with tcp, you can define the adapter as following:
|
||||||
|
</para>
|
||||||
|
<programlisting language="xml"><![CDATA[<int-splunk:outbound-channel-adapter
|
||||||
|
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
|
||||||
|
channel="outputToSplunk" splunk-server-ref="splunkServer"
|
||||||
|
ingest="tcp" tcpPort="9999">
|
||||||
|
</int-splunk:outbound-channel-adapter>]]></programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
To use outbound channel adapter with stream, you can define the adapter as following:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<programlisting language="xml"><![CDATA[<int-splunk:outbound-channel-adapter
|
||||||
|
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
|
||||||
|
channel="outputToSplunk" splunk-server-ref="splunkServer"
|
||||||
|
ingest="stream">
|
||||||
|
</int-splunk:outbound-channel-adapter>]]></programlisting>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="splunk-inbound-channel-adapter">
|
||||||
|
<title>Inbound Channel Adapter</title>
|
||||||
|
<para>
|
||||||
|
Inbound channel adapter is used to get data out of Splunk and put
|
||||||
|
into Spring Integration's channel.
|
||||||
|
There are 5 ways to get data out of Splunk:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>Blocking</listitem>
|
||||||
|
<listitem>Non blocking</listitem>
|
||||||
|
<listitem>Saved search</listitem>
|
||||||
|
<listitem>Realtime</listitem>
|
||||||
|
<listitem>Export</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
For more information on the difference, please refer
|
||||||
|
<ulink url="https://github.com/splunk/splunk-sdk-java/tree/master/examples">Splunk SDK</ulink>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
To use bloking inbound channel adapter, you can define the adapter as following:
|
||||||
|
</para>
|
||||||
|
<programlisting language="xml"><![CDATA[<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||||
|
auto-startup="true" search="search spring:example"
|
||||||
|
splunk-server-ref="splunkServer"
|
||||||
|
channel="inputFromSplunk" mode="blocking" initEarliestTime="-1d">
|
||||||
|
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||||
|
</int-splunk:inbound-channel-adapter>]]></programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
To use non blocking inbound channel adapter, you can define the adapter as following:
|
||||||
|
</para>
|
||||||
|
<programlisting language="xml"><![CDATA[<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||||
|
auto-startup="true" search="search spring:example"
|
||||||
|
splunk-server-ref="splunkServer"
|
||||||
|
channel="inputFromSplunk" mode="normal" initEarliestTime="-1d">
|
||||||
|
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||||
|
</int-splunk:inbound-channel-adapter>]]></programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
To use saved search inbound channel adapter, you can define the adapter as following:
|
||||||
|
</para>
|
||||||
|
<programlisting language="xml"><![CDATA[<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||||
|
auto-startup="true" savedSearch="test" splunk-server-ref="splunkServer"
|
||||||
|
splunk-server-ref="splunkServer"
|
||||||
|
channel="inputFromSplunk" mode="saved" initEarliestTime="-1d">
|
||||||
|
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||||
|
</int-splunk:inbound-channel-adapter>]]></programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
To use realtime search inbound channel adapter, you can define the adapter as following:
|
||||||
|
</para>
|
||||||
|
<programlisting language="xml"><![CDATA[<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||||
|
auto-startup="true" search="search spring:example"
|
||||||
|
splunk-server-ref="splunkServer"
|
||||||
|
channel="inputFromSplunk" mode="realtime" initEarliestTime="-1d">
|
||||||
|
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||||
|
</int-splunk:inbound-channel-adapter>]]></programlisting>
|
||||||
|
<para>
|
||||||
|
To use export inbound channel adapter, you can define the adapter as following:
|
||||||
|
</para>
|
||||||
|
<programlisting language="xml"><![CDATA[<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||||
|
auto-startup="true" search="search spring:example"
|
||||||
|
splunk-server-ref="splunkServer"
|
||||||
|
channel="inputFromSplunk" mode="export" initEarliestTime="-1d">
|
||||||
|
<int:poller fixed-rate="5" time-unit="SECONDS"/>
|
||||||
|
</int-splunk:inbound-channel-adapter>]]></programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
As Splunk support range search, you can specify the search rage by using
|
||||||
|
"latestTime", "earliestTime", "initEarliestTime".
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
"initEarliestTime" is the value for "earliestTime" when the application first start.
|
||||||
|
If you specify "earliestTime" and "latestTime", the poller will only search data
|
||||||
|
in that range. Otherwise, the range will move forward as time goes. That means, the
|
||||||
|
"latestTime" is equal to the time where the polling trigger, the "earliestTime" is
|
||||||
|
equal to the time where the last polling is run.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
You can get more information on the rage search from
|
||||||
|
<ulink url="http://docs.splunk.com/Documentation/Splunk/latest/User/ChangeTheTimeRangeOfYourSearch">
|
||||||
|
Splunk</ulink>.
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
</chapter>
|
||||||
17
src/reference/docbook/whats-new.xml
Normal file
17
src/reference/docbook/whats-new.xml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<chapter xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="whats-new"
|
||||||
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<title>What's new?</title>
|
||||||
|
<para>
|
||||||
|
The Spring Integration adapter for Splunk includes two adapters:
|
||||||
|
</para>
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
Inbound Channel Adapter to search data from Splunk.
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
Outbound Channel Adapter to push event data into Splunk.
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</chapter>
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.config.xml;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||||
|
import org.springframework.integration.splunk.support.SearchMode;
|
||||||
|
import org.springframework.integration.splunk.support.SplunkDataReader;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@ContextConfiguration
|
||||||
|
public class SplunkInboundChannelAdapterParserSavedSearchTests {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationContext appContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.config.xml.SplunkInboundChannelAdapterParser#parseSource(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testParseSourceElementParserContext() {
|
||||||
|
SourcePollingChannelAdapter adapter = appContext.getBean("splunkInboundChannelAdapter",
|
||||||
|
SourcePollingChannelAdapter.class);
|
||||||
|
Assert.assertNotNull(adapter);
|
||||||
|
|
||||||
|
SplunkDataReader reader = appContext.getBean("splunkInboundChannelAdapter.splunkExecutor.reader",
|
||||||
|
SplunkDataReader.class);
|
||||||
|
Assert.assertNotNull(reader);
|
||||||
|
|
||||||
|
SearchMode mode = SearchMode.saved;
|
||||||
|
Assert.assertEquals(mode, reader.getMode());
|
||||||
|
|
||||||
|
String savedSearch = "savedSearch";
|
||||||
|
Assert.assertEquals(savedSearch, reader.getSavedSearch());
|
||||||
|
|
||||||
|
String owner = "admin";
|
||||||
|
Assert.assertEquals(owner, reader.getOwner());
|
||||||
|
|
||||||
|
String app = "search";
|
||||||
|
Assert.assertEquals(app, reader.getApp());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.config.xml;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||||
|
import org.springframework.integration.splunk.support.SearchMode;
|
||||||
|
import org.springframework.integration.splunk.support.SplunkDataReader;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@ContextConfiguration
|
||||||
|
public class SplunkInboundChannelAdapterParserTests {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationContext appContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.config.xml.SplunkInboundChannelAdapterParser#parseSource(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
//@Ignore
|
||||||
|
public void testParseSourceElementParserContext() {
|
||||||
|
SourcePollingChannelAdapter adapter = appContext.getBean("splunkInboundChannelAdapter",
|
||||||
|
SourcePollingChannelAdapter.class);
|
||||||
|
Assert.assertNotNull(adapter);
|
||||||
|
Assert.assertFalse(adapter.isAutoStartup());
|
||||||
|
|
||||||
|
SplunkDataReader reader = appContext.getBean("splunkInboundChannelAdapter.splunkExecutor.reader",
|
||||||
|
SplunkDataReader.class);
|
||||||
|
Assert.assertNotNull(reader);
|
||||||
|
|
||||||
|
String searchString = "search spring:example";
|
||||||
|
Assert.assertEquals(searchString, reader.getSearch());
|
||||||
|
|
||||||
|
SearchMode mode = SearchMode.blocking;
|
||||||
|
Assert.assertEquals(mode, reader.getMode());
|
||||||
|
|
||||||
|
String earliestTime = "-1d";
|
||||||
|
Assert.assertEquals(earliestTime, reader.getEarliestTime());
|
||||||
|
|
||||||
|
String latestTime = "now";
|
||||||
|
Assert.assertEquals(latestTime, reader.getLatestTime());
|
||||||
|
|
||||||
|
String initEarliestTime = "-1d";
|
||||||
|
Assert.assertEquals(initEarliestTime, reader.getInitEarliestTime());
|
||||||
|
|
||||||
|
String fieldList = "field1, field2";
|
||||||
|
Assert.assertEquals(fieldList, reader.getFieldList());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.config.xml;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.integration.splunk.support.IngestType;
|
||||||
|
import org.springframework.integration.splunk.support.SplunkDataWriter;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@ContextConfiguration
|
||||||
|
public class SplunkOutboundChannelAdapterParserStreamTests {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationContext appContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.config.xml.SplunkOutboundChannelAdapterParser#parseConsumer(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testParseConsumerElementParserContext() {
|
||||||
|
Object adapter = appContext.getBean("splunkOutboundChannelAdapter");
|
||||||
|
Assert.assertNotNull(adapter);
|
||||||
|
|
||||||
|
SplunkDataWriter writer = appContext.getBean("splunkOutboundChannelAdapter.splunkExecutor.writer",
|
||||||
|
SplunkDataWriter.class);
|
||||||
|
Assert.assertNotNull(writer);
|
||||||
|
|
||||||
|
IngestType ingest = IngestType.stream;
|
||||||
|
Assert.assertEquals(ingest, writer.getIngest());
|
||||||
|
|
||||||
|
String host = "test.host";
|
||||||
|
Assert.assertEquals(host, writer.getHost());
|
||||||
|
|
||||||
|
String hostRegex = "test.host.*";
|
||||||
|
Assert.assertEquals(hostRegex, writer.getHostRegex());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.config.xml;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.integration.splunk.support.IngestType;
|
||||||
|
import org.springframework.integration.splunk.support.SplunkDataWriter;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@ContextConfiguration
|
||||||
|
public class SplunkOutboundChannelAdapterParserTests {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationContext appContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.config.xml.SplunkOutboundChannelAdapterParser#parseConsumer(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testParseConsumerElementParserContext() {
|
||||||
|
Object adapter = appContext.getBean("splunkOutboundChannelAdapter");
|
||||||
|
Assert.assertNotNull(adapter);
|
||||||
|
|
||||||
|
SplunkDataWriter writer = appContext.getBean("splunkOutboundChannelAdapter.splunkExecutor.writer",
|
||||||
|
SplunkDataWriter.class);
|
||||||
|
Assert.assertNotNull(writer);
|
||||||
|
|
||||||
|
String sourceType = "spring-integration";
|
||||||
|
Assert.assertEquals(sourceType, writer.getSourceType());
|
||||||
|
|
||||||
|
String source = "example5";
|
||||||
|
Assert.assertEquals(source, writer.getSource());
|
||||||
|
|
||||||
|
IngestType ingest = IngestType.submit;
|
||||||
|
Assert.assertEquals(ingest, writer.getIngest());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.config.xml;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkServer;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@ContextConfiguration
|
||||||
|
public class SplunkServerParserTests {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationContext appContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.config.xml.SplunkServerParser#doParse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext, org.springframework.beans.factory.support.BeanDefinitionBuilder)}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testDoParseElementParserContextBeanDefinitionBuilder() {
|
||||||
|
SplunkServer server = appContext.getBean("splunkServer", SplunkServer.class);
|
||||||
|
|
||||||
|
Assert.assertEquals("test.splunk.server", server.getHost());
|
||||||
|
Assert.assertEquals(8089, server.getPort());
|
||||||
|
Assert.assertEquals("admin", server.getUserName());
|
||||||
|
Assert.assertEquals("password", server.getPassword());
|
||||||
|
Assert.assertEquals("https", server.getScheme());
|
||||||
|
Assert.assertEquals("admin", server.getOwner());
|
||||||
|
Assert.assertEquals("search", server.getApp());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.inbound;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkData;
|
||||||
|
import org.springframework.integration.splunk.support.SplunkExecutor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkPollingChannelAdapterTests {
|
||||||
|
|
||||||
|
private SplunkPollingChannelAdapter inboundAdapter;
|
||||||
|
|
||||||
|
private SplunkExecutor executor;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void init() {
|
||||||
|
executor = mock(SplunkExecutor.class);
|
||||||
|
inboundAdapter = new SplunkPollingChannelAdapter(executor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.inbound.SplunkPollingChannelAdapter#receive()}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testReceive() {
|
||||||
|
List<SplunkData> data = new ArrayList<SplunkData>();
|
||||||
|
SplunkData sd = new SplunkData("spring", "spring:example");
|
||||||
|
sd.setCommonDesc("description");
|
||||||
|
data.add(sd);
|
||||||
|
when(executor.poll()).thenReturn(data);
|
||||||
|
|
||||||
|
List<SplunkData> received = inboundAdapter.receive().getPayload();
|
||||||
|
Assert.assertEquals(1, received.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.inbound.SplunkPollingChannelAdapter#getComponentType()}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetComponentType() {
|
||||||
|
Assert.assertEquals("splunk:inbound-channel-adapter", inboundAdapter.getComponentType());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.outbound;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.integration.Message;
|
||||||
|
import org.springframework.integration.splunk.support.SplunkExecutor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkOutboundChannelAdapterTests {
|
||||||
|
|
||||||
|
private SplunkOutboundChannelAdapter outboundAdapter;
|
||||||
|
|
||||||
|
private SplunkExecutor executor;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void init() {
|
||||||
|
executor = mock(SplunkExecutor.class);
|
||||||
|
outboundAdapter = new SplunkOutboundChannelAdapter(executor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.outbound.SplunkOutboundChannelAdapter#handleRequestMessage(org.springframework.integration.Message)}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testHandleRequestMessage() {
|
||||||
|
Message<?> message = null;
|
||||||
|
when(executor.executeOutboundOperation(message)).thenReturn(null);
|
||||||
|
|
||||||
|
Object ret = outboundAdapter.handleRequestMessage(message);
|
||||||
|
Assert.assertNull(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.outbound.SplunkOutboundChannelAdapter#setProducesReply(boolean)}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testSetProducesReply() {
|
||||||
|
outboundAdapter.setProducesReply(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.support;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.integration.splunk.core.ConnectionFactory;
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkServer;
|
||||||
|
|
||||||
|
import com.splunk.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ConnectionFactoryFactoryBeanTests {
|
||||||
|
|
||||||
|
private ConnectionFactoryFactoryBean<Service> factoryBean;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.support.ConnectionFactoryFactoryBean#ConnectionFactoryFactoryBean(org.springframework.integration.splunk.core.ConnectionFactory, boolean)}.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testConnectionFactoryFactoryBean() throws Exception {
|
||||||
|
SplunkServer server = new SplunkServer();
|
||||||
|
SplunkConnectionFactory factory = new SplunkConnectionFactory(server);
|
||||||
|
factoryBean = new ConnectionFactoryFactoryBean<Service>(factory, false);
|
||||||
|
|
||||||
|
ConnectionFactory<Service> generatedByFactoryBean = factoryBean.getObject();
|
||||||
|
Assert.assertTrue(generatedByFactoryBean instanceof SplunkConnectionFactory);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConnectionFactoryFactoryBean_withPoll() throws Exception {
|
||||||
|
SplunkServer server = new SplunkServer();
|
||||||
|
SplunkConnectionFactory factory = new SplunkConnectionFactory(server);
|
||||||
|
factoryBean = new ConnectionFactoryFactoryBean<Service>(factory, true);
|
||||||
|
|
||||||
|
ConnectionFactory<Service> generatedByFactoryBean = factoryBean.getObject();
|
||||||
|
Assert.assertTrue(generatedByFactoryBean instanceof PoolingConnectionFactory);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.support.ConnectionFactoryFactoryBean#getObjectType()}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetObjectType() {
|
||||||
|
SplunkServer server = new SplunkServer();
|
||||||
|
SplunkConnectionFactory factory = new SplunkConnectionFactory(server);
|
||||||
|
factoryBean = new ConnectionFactoryFactoryBean<Service>(factory, true);
|
||||||
|
|
||||||
|
Class<?> clazz = factoryBean.getObjectType();
|
||||||
|
Assert.assertEquals(PoolingConnectionFactory.class, clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.support.ConnectionFactoryFactoryBean#isSingleton()}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testIsSingleton() {
|
||||||
|
SplunkServer server = new SplunkServer();
|
||||||
|
SplunkConnectionFactory factory = new SplunkConnectionFactory(server);
|
||||||
|
factoryBean = new ConnectionFactoryFactoryBean<Service>(factory, false);
|
||||||
|
|
||||||
|
Assert.assertTrue(factoryBean.isSingleton());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.support;
|
||||||
|
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.integration.splunk.core.Connection;
|
||||||
|
import org.springframework.integration.splunk.core.ConnectionFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PoolingConnectionFactoryTests {
|
||||||
|
|
||||||
|
private ConnectionFactory<TestEntity> conFactory;
|
||||||
|
|
||||||
|
private PoolingConnectionFactory<TestEntity> poolConFactory;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Before
|
||||||
|
public void before() {
|
||||||
|
conFactory = mock(ConnectionFactory.class);
|
||||||
|
poolConFactory = new PoolingConnectionFactory<TestEntity>(conFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.support.PoolingConnectionFactory#getConnection()}.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetConnection() throws Exception {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Connection<TestEntity> con = mock(Connection.class);
|
||||||
|
|
||||||
|
when(con.getTarget()).thenReturn(new TestEntity("entity1"));
|
||||||
|
when(conFactory.getConnection()).thenReturn(con);
|
||||||
|
Connection<TestEntity> returnCon = poolConFactory.getConnection();
|
||||||
|
TestEntity obj1 = returnCon.getTarget();
|
||||||
|
Assert.assertNotNull(obj1);
|
||||||
|
Assert.assertEquals("entity1", obj1.getName());
|
||||||
|
|
||||||
|
when(con.getTarget()).thenReturn(new TestEntity("entity2"));
|
||||||
|
when(conFactory.getConnection()).thenReturn(con);
|
||||||
|
returnCon = poolConFactory.getConnection();
|
||||||
|
TestEntity obj2 = returnCon.getTarget();
|
||||||
|
Assert.assertNotNull(obj2);
|
||||||
|
Assert.assertEquals("entity2", obj2.getName());
|
||||||
|
|
||||||
|
when(con.getTarget()).thenReturn(new TestEntity("entity3"));
|
||||||
|
when(conFactory.getConnection()).thenReturn(con);
|
||||||
|
returnCon = poolConFactory.getConnection();
|
||||||
|
TestEntity obj3 = returnCon.getTarget();
|
||||||
|
Assert.assertNotNull(obj3);
|
||||||
|
Assert.assertEquals("entity3", obj3.getName());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.support.PoolingConnectionFactory#destroy()}.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test(expected = IllegalStateException.class)
|
||||||
|
public void testDestroy() throws Exception {
|
||||||
|
try {
|
||||||
|
poolConFactory.destroy();
|
||||||
|
} catch (Exception e) {
|
||||||
|
fail("exception when destoying pool connection factory");
|
||||||
|
}
|
||||||
|
poolConFactory.getConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TestEntity {
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public TestEntity(String n) {
|
||||||
|
this.name = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.support;
|
||||||
|
|
||||||
|
import static org.mockito.Matchers.any;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.integration.splunk.core.Connection;
|
||||||
|
import org.springframework.integration.splunk.core.ConnectionFactory;
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkData;
|
||||||
|
|
||||||
|
import com.splunk.Job;
|
||||||
|
import com.splunk.JobCollection;
|
||||||
|
import com.splunk.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkDataReaderTests {
|
||||||
|
|
||||||
|
private SplunkDataReader reader;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before() {
|
||||||
|
reader = new SplunkDataReader(new TestConnectioniFactory());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.support.SplunkDataReader#search()}.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testBlockingSearch() throws Exception {
|
||||||
|
reader.setMode(SearchMode.blocking);
|
||||||
|
reader.setSearch("search spring:example");
|
||||||
|
List<SplunkData> data = reader.search();
|
||||||
|
Assert.assertNotNull(data);
|
||||||
|
Assert.assertEquals(5, data.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNonBlockingSearch() throws Exception {
|
||||||
|
reader.setMode(SearchMode.normal);
|
||||||
|
reader.setSearch("search spring:example");
|
||||||
|
List<SplunkData> data = reader.search();
|
||||||
|
Assert.assertNotNull(data);
|
||||||
|
Assert.assertEquals(5, data.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRealtimeSearch() throws Exception {
|
||||||
|
reader.setMode(SearchMode.realtime);
|
||||||
|
reader.setSearch("search spring:example");
|
||||||
|
List<SplunkData> data = reader.search();
|
||||||
|
Assert.assertNotNull(data);
|
||||||
|
Assert.assertEquals(5, data.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TestConnectioniFactory implements ConnectionFactory<Service> {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.ConnectionFactory#getConnection()
|
||||||
|
*/
|
||||||
|
public Connection<Service> getConnection() throws Exception {
|
||||||
|
return new TestConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TestConnection implements Connection<Service> {
|
||||||
|
|
||||||
|
private Service service = mock(Service.class);
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.Connection#getTarget()
|
||||||
|
*/
|
||||||
|
public Service getTarget() {
|
||||||
|
InputStream is = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
is = new ClassPathResource("splunk-data.xml").getInputStream();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
Assert.fail("can not read splunk data file");
|
||||||
|
} catch (IOException e) {
|
||||||
|
Assert.fail("can not read splunk data file");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
service.setToken("token");
|
||||||
|
JobCollection jobCollection = mock(JobCollection.class);
|
||||||
|
Job blockingJob = mock(Job.class);
|
||||||
|
when(blockingJob.isDone()).thenReturn(true);
|
||||||
|
when(blockingJob.getResultCount()).thenReturn(5);
|
||||||
|
when(blockingJob.getResults(any(Map.class))).thenReturn(is);
|
||||||
|
when(jobCollection.create(any(String.class), any(Map.class))).thenReturn(blockingJob);
|
||||||
|
when(service.getJobs()).thenReturn(jobCollection);
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.Connection#close()
|
||||||
|
*/
|
||||||
|
public void close() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.Connection#isOpen()
|
||||||
|
*/
|
||||||
|
public boolean isOpen() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.support;
|
||||||
|
|
||||||
|
import static org.mockito.Matchers.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.integration.splunk.core.Connection;
|
||||||
|
import org.springframework.integration.splunk.core.ConnectionFactory;
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkData;
|
||||||
|
|
||||||
|
import com.splunk.Args;
|
||||||
|
import com.splunk.Receiver;
|
||||||
|
import com.splunk.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkDataWriterTests {
|
||||||
|
|
||||||
|
private SplunkDataWriter writer;
|
||||||
|
|
||||||
|
private static Receiver receiver = mock(Receiver.class);
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before() {
|
||||||
|
writer = new SplunkDataWriter(new TestConnectioniFactory());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.support.SplunkDataWriter#write(org.springframework.integration.splunk.entity.SplunkData)}.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testWrite() throws Exception {
|
||||||
|
writer.setIngest(IngestType.submit);
|
||||||
|
|
||||||
|
SplunkData sd = new SplunkData("spring", "spring:example");
|
||||||
|
sd.setCommonDesc("description");
|
||||||
|
writer.write(sd);
|
||||||
|
Args args = new Args();
|
||||||
|
verify(receiver).submit(eq(args), matches(".*spring:example.*"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TestConnectioniFactory implements ConnectionFactory<Service> {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.ConnectionFactory#getConnection()
|
||||||
|
*/
|
||||||
|
public Connection<Service> getConnection() throws Exception {
|
||||||
|
return new TestConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TestConnection implements Connection<Service> {
|
||||||
|
|
||||||
|
private Service service = mock(Service.class);
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.Connection#getTarget()
|
||||||
|
*/
|
||||||
|
public Service getTarget() {
|
||||||
|
service.setToken("token");
|
||||||
|
when(service.getReceiver()).thenReturn(receiver);
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.Connection#close()
|
||||||
|
*/
|
||||||
|
public void close() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.springframework.integration.splunk.core.Connection#isOpen()
|
||||||
|
*/
|
||||||
|
public boolean isOpen() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2012 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.integration.splunk.support;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.integration.Message;
|
||||||
|
import org.springframework.integration.splunk.core.DataReader;
|
||||||
|
import org.springframework.integration.splunk.core.DataWriter;
|
||||||
|
import org.springframework.integration.splunk.entity.SplunkData;
|
||||||
|
import org.springframework.integration.support.MessageBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Jarred Li
|
||||||
|
* @since 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SplunkExecutorTests {
|
||||||
|
|
||||||
|
private SplunkExecutor executor;
|
||||||
|
|
||||||
|
private DataReader reader = mock(DataReader.class);
|
||||||
|
|
||||||
|
private DataWriter writer = mock(DataWriter.class);
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before() {
|
||||||
|
executor = new SplunkExecutor();
|
||||||
|
executor.setReader(reader);
|
||||||
|
executor.setWriter(writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.support.SplunkExecutor#handleMessage(org.springframework.integration.Message)}.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testHandleMessage() throws Exception {
|
||||||
|
SplunkData sd = new SplunkData("spring", "spring:example");
|
||||||
|
sd.setCommonDesc("description");
|
||||||
|
Message<SplunkData> message = MessageBuilder.withPayload(sd).build();
|
||||||
|
executor.handleMessage(message);
|
||||||
|
verify(writer).write(sd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link org.springframework.integration.splunk.support.SplunkExecutor#poll()}.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testPoll() throws Exception {
|
||||||
|
List<SplunkData> data = new ArrayList<SplunkData>();
|
||||||
|
SplunkData sd = new SplunkData("spring", "spring:example");
|
||||||
|
sd.setCommonDesc("description");
|
||||||
|
data.add(sd);
|
||||||
|
|
||||||
|
sd = new SplunkData("spring", "spring:example");
|
||||||
|
sd.setCommonDesc("description");
|
||||||
|
data.add(sd);
|
||||||
|
when(reader.search()).thenReturn(data);
|
||||||
|
|
||||||
|
List<SplunkData> result = executor.poll();
|
||||||
|
Assert.assertEquals(2, result.size());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
5
src/test/resources/log4j.properties
Normal file
5
src/test/resources/log4j.properties
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
log4j.rootCategory=INFO, stdout
|
||||||
|
|
||||||
|
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||||
|
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:int="http://www.springframework.org/schema/integration"
|
||||||
|
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||||
|
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||||
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||||
|
http://www.springframework.org/schema/integration/splunk http://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||||
|
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||||
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||||
|
|
||||||
|
<context:component-scan base-package="org.springframework.integration"></context:component-scan>
|
||||||
|
<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"/>
|
||||||
|
|
||||||
|
<int-splunk:server id="splunkServer" host="10.112.127.51" port="8089" userName="admin" password="password" owner="admin"/>
|
||||||
|
|
||||||
|
</beans>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:int="http://www.springframework.org/schema/integration"
|
||||||
|
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||||
|
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||||
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||||
|
http://www.springframework.org/schema/integration/splunk http://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||||
|
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||||
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||||
|
|
||||||
|
<import resource="../../SplunkCommon-context.xml"/>
|
||||||
|
<context:component-scan base-package="org.springframework.integration.splunk.inbound"></context:component-scan>
|
||||||
|
<int:channel id="inputFromSplunk">
|
||||||
|
</int:channel>
|
||||||
|
<stream:stdout-channel-adapter id="stdout" channel="inputFromSplunk" append-newline="true"/>
|
||||||
|
|
||||||
|
|
||||||
|
</beans>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:int="http://www.springframework.org/schema/integration"
|
||||||
|
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||||
|
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||||
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||||
|
http://www.springframework.org/schema/integration/splunk http://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||||
|
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||||
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||||
|
|
||||||
|
<import resource="SplunkInboundChannelAdapterParserCommon-context.xml"/>
|
||||||
|
|
||||||
|
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||||
|
auto-startup="false"
|
||||||
|
splunk-server-ref="splunkServer"
|
||||||
|
channel="inputFromSplunk" mode="saved" earliestTime="-1d" latestTime="now"
|
||||||
|
initEarliestTime="-1d" count="1000"
|
||||||
|
savedSearch="savedSearch" owner="admin" app="search">
|
||||||
|
<int:poller fixed-rate="5000"/>
|
||||||
|
</int-splunk:inbound-channel-adapter>
|
||||||
|
|
||||||
|
</beans>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:int="http://www.springframework.org/schema/integration"
|
||||||
|
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||||
|
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||||
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||||
|
http://www.springframework.org/schema/integration/splunk http://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||||
|
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||||
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||||
|
|
||||||
|
<import resource="SplunkInboundChannelAdapterParserCommon-context.xml"/>
|
||||||
|
|
||||||
|
<int-splunk:inbound-channel-adapter id="splunkInboundChannelAdapter"
|
||||||
|
auto-startup="false" search="search spring:example"
|
||||||
|
splunk-server-ref="splunkServer"
|
||||||
|
channel="inputFromSplunk" mode="blocking" earliestTime="-1d" latestTime="now"
|
||||||
|
initEarliestTime="-1d" fieldList="field1, field2">
|
||||||
|
<int:poller fixed-rate="5000"/>
|
||||||
|
</int-splunk:inbound-channel-adapter>
|
||||||
|
|
||||||
|
</beans>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
|
||||||
|
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||||
|
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||||
|
xsi:schemaLocation="
|
||||||
|
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||||
|
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||||
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
|
http://www.springframework.org/schema/integration/splunk http://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd">
|
||||||
|
|
||||||
|
<import resource="../../SplunkCommon-context.xml" />
|
||||||
|
|
||||||
|
<int:channel id="outputToSplunk">
|
||||||
|
</int:channel>
|
||||||
|
|
||||||
|
<int-splunk:outbound-channel-adapter
|
||||||
|
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
|
||||||
|
channel="outputToSplunk" splunk-server-ref="splunkServer"
|
||||||
|
pool-server-connection="true" sourceType="spring-integration" source="example5"
|
||||||
|
ingest="stream" host="test.host" hostRegex="test.host.*">
|
||||||
|
</int-splunk:outbound-channel-adapter>
|
||||||
|
|
||||||
|
</beans>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
|
||||||
|
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||||
|
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||||
|
xsi:schemaLocation="
|
||||||
|
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||||
|
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||||
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
|
http://www.springframework.org/schema/integration/splunk http://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd">
|
||||||
|
|
||||||
|
<import resource="../../SplunkCommon-context.xml" />
|
||||||
|
|
||||||
|
<int:channel id="outputToSplunk">
|
||||||
|
</int:channel>
|
||||||
|
|
||||||
|
<int-splunk:outbound-channel-adapter
|
||||||
|
id="splunkOutboundChannelAdapter" auto-startup="true" order="1"
|
||||||
|
channel="outputToSplunk" splunk-server-ref="splunkServer"
|
||||||
|
pool-server-connection="true" sourceType="spring-integration" source="example5"
|
||||||
|
ingest="submit">
|
||||||
|
</int-splunk:outbound-channel-adapter>
|
||||||
|
|
||||||
|
</beans>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
|
||||||
|
xmlns:int-splunk="http://www.springframework.org/schema/integration/splunk"
|
||||||
|
xmlns:stream="http://www.springframework.org/schema/integration/stream"
|
||||||
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
|
||||||
|
http://www.springframework.org/schema/integration/splunk http://www.springframework.org/schema/integration/splunk/spring-integration-splunk.xsd
|
||||||
|
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||||
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||||
|
|
||||||
|
<int-splunk:server id="splunkServer" host="test.splunk.server"
|
||||||
|
port="8089" userName="admin" password="password" owner="admin" app="search"
|
||||||
|
scheme="https" />
|
||||||
|
|
||||||
|
</beans>
|
||||||
236
src/test/resources/splunk-data.xml
Normal file
236
src/test/resources/splunk-data.xml
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<results preview='0'>
|
||||||
|
<meta>
|
||||||
|
<fieldOrder>
|
||||||
|
<field>_cd</field>
|
||||||
|
<field>_indextime</field>
|
||||||
|
<field>_raw</field>
|
||||||
|
<field>_serial</field>
|
||||||
|
<field>_si</field>
|
||||||
|
<field>_sourcetype</field>
|
||||||
|
<field>_subsecond</field>
|
||||||
|
<field>_time</field>
|
||||||
|
<field>host</field>
|
||||||
|
<field>index</field>
|
||||||
|
<field>linecount</field>
|
||||||
|
<field>source</field>
|
||||||
|
<field>sourcetype</field>
|
||||||
|
<field>splunk_server</field>
|
||||||
|
</fieldOrder>
|
||||||
|
</meta>
|
||||||
|
<result offset='0'>
|
||||||
|
<field k='_cd'>
|
||||||
|
<value><text>9:30</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_indextime'>
|
||||||
|
<value><text>1348478076</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_raw'><v xml:space='preserve' trunc='0'>2012-09-24 17:19:43:792+0800 name="spring" event_id="<sg h='1'>spring:example</sg>" desc="description"</v></field>
|
||||||
|
<field k='_serial'>
|
||||||
|
<value><text>0</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_si'>
|
||||||
|
<value><text>jarred-virtual-machine</text></value>
|
||||||
|
<value><text>main</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_sourcetype'>
|
||||||
|
<value><text>spring-integration</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_subsecond'>
|
||||||
|
<value><text>.792</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_time'>
|
||||||
|
<value><text>2012-09-24T17:19:43.792+08:00</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='host'>
|
||||||
|
<value><text>test.host</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='index'>
|
||||||
|
<value><text>main</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='linecount'>
|
||||||
|
<value><text>1</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='source'>
|
||||||
|
<value><text>example5</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='sourcetype'>
|
||||||
|
<value><text>spring-integration</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='splunk_server'>
|
||||||
|
<value><text>jarred-virtual-machine</text></value>
|
||||||
|
</field>
|
||||||
|
</result>
|
||||||
|
<result offset='1'>
|
||||||
|
<field k='_cd'>
|
||||||
|
<value><text>9:26</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_indextime'>
|
||||||
|
<value><text>1348478076</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_raw'><v xml:space='preserve' trunc='0'>2012-09-24 17:19:43:756+0800 name="spring" event_id="<sg h='1'>spring:example</sg>" desc="description"</v></field>
|
||||||
|
<field k='_serial'>
|
||||||
|
<value><text>1</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_si'>
|
||||||
|
<value><text>jarred-virtual-machine</text></value>
|
||||||
|
<value><text>main</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_sourcetype'>
|
||||||
|
<value><text>spring-integration</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_subsecond'>
|
||||||
|
<value><text>.756</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_time'>
|
||||||
|
<value><text>2012-09-24T17:19:43.756+08:00</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='host'>
|
||||||
|
<value><text>test.host</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='index'>
|
||||||
|
<value><text>main</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='linecount'>
|
||||||
|
<value><text>1</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='source'>
|
||||||
|
<value><text>example5</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='sourcetype'>
|
||||||
|
<value><text>spring-integration</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='splunk_server'>
|
||||||
|
<value><text>jarred-virtual-machine</text></value>
|
||||||
|
</field>
|
||||||
|
</result>
|
||||||
|
<result offset='2'>
|
||||||
|
<field k='_cd'>
|
||||||
|
<value><text>9:21</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_indextime'>
|
||||||
|
<value><text>1348464748</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_raw'><v xml:space='preserve' trunc='0'>2012-09-24 13:37:34:860+0800 name="spring" event_id="<sg h='1'>spring:example</sg>" desc="description"</v></field>
|
||||||
|
<field k='_serial'>
|
||||||
|
<value><text>2</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_si'>
|
||||||
|
<value><text>jarred-virtual-machine</text></value>
|
||||||
|
<value><text>main</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_sourcetype'>
|
||||||
|
<value><text>spring-integration</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_subsecond'>
|
||||||
|
<value><text>.860</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_time'>
|
||||||
|
<value><text>2012-09-24T13:37:34.860+08:00</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='host'>
|
||||||
|
<value><text>test.host</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='index'>
|
||||||
|
<value><text>main</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='linecount'>
|
||||||
|
<value><text>1</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='source'>
|
||||||
|
<value><text>example5</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='sourcetype'>
|
||||||
|
<value><text>spring-integration</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='splunk_server'>
|
||||||
|
<value><text>jarred-virtual-machine</text></value>
|
||||||
|
</field>
|
||||||
|
</result>
|
||||||
|
<result offset='3'>
|
||||||
|
<field k='_cd'>
|
||||||
|
<value><text>9:17</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_indextime'>
|
||||||
|
<value><text>1348464748</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_raw'><v xml:space='preserve' trunc='0'>2012-09-24 13:37:34:789+0800 name="spring" event_id="<sg h='1'>spring:example</sg>" desc="description"</v></field>
|
||||||
|
<field k='_serial'>
|
||||||
|
<value><text>3</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_si'>
|
||||||
|
<value><text>jarred-virtual-machine</text></value>
|
||||||
|
<value><text>main</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_sourcetype'>
|
||||||
|
<value><text>spring-integration</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_subsecond'>
|
||||||
|
<value><text>.789</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_time'>
|
||||||
|
<value><text>2012-09-24T13:37:34.789+08:00</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='host'>
|
||||||
|
<value><text>test.host</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='index'>
|
||||||
|
<value><text>main</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='linecount'>
|
||||||
|
<value><text>1</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='source'>
|
||||||
|
<value><text>example5</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='sourcetype'>
|
||||||
|
<value><text>spring-integration</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='splunk_server'>
|
||||||
|
<value><text>jarred-virtual-machine</text></value>
|
||||||
|
</field>
|
||||||
|
</result>
|
||||||
|
<result offset='4'>
|
||||||
|
<field k='_cd'>
|
||||||
|
<value><text>9:12</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_indextime'>
|
||||||
|
<value><text>1348464606</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_raw'><v xml:space='preserve' trunc='0'>2012-09-24 13:35:13:621+0800 name="spring" event_id="<sg h='1'>spring:example</sg>" desc="description"</v></field>
|
||||||
|
<field k='_serial'>
|
||||||
|
<value><text>4</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_si'>
|
||||||
|
<value><text>jarred-virtual-machine</text></value>
|
||||||
|
<value><text>main</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_sourcetype'>
|
||||||
|
<value><text>spring-integration</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_subsecond'>
|
||||||
|
<value><text>.621</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='_time'>
|
||||||
|
<value><text>2012-09-24T13:35:13.621+08:00</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='host'>
|
||||||
|
<value><text>test.host</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='index'>
|
||||||
|
<value><text>main</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='linecount'>
|
||||||
|
<value><text>1</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='source'>
|
||||||
|
<value><text>example5</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='sourcetype'>
|
||||||
|
<value><text>spring-integration</text></value>
|
||||||
|
</field>
|
||||||
|
<field k='splunk_server'>
|
||||||
|
<value><text>jarred-virtual-machine</text></value>
|
||||||
|
</field>
|
||||||
|
</result>
|
||||||
|
</results>
|
||||||
Reference in New Issue
Block a user