logstash-core 1.5.0.beta2-java → 1.5.0-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of logstash-core might be problematic. Click here for more details.

Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/lib/logstash-core.rb +2 -0
  3. data/lib/logstash/agent.rb +0 -41
  4. data/lib/logstash/config/config_ast.rb +62 -29
  5. data/lib/logstash/config/mixin.rb +3 -3
  6. data/lib/logstash/environment.rb +37 -100
  7. data/lib/logstash/event.rb +32 -20
  8. data/lib/logstash/filters/base.rb +20 -0
  9. data/lib/logstash/java_integration.rb +72 -18
  10. data/lib/logstash/namespace.rb +0 -3
  11. data/lib/logstash/outputs/base.rb +1 -1
  12. data/lib/logstash/patches/bundler.rb +20 -0
  13. data/lib/logstash/patches/rubygems.rb +37 -0
  14. data/lib/logstash/pipeline.rb +59 -39
  15. data/lib/logstash/runner.rb +4 -50
  16. data/lib/logstash/util.rb +0 -1
  17. data/lib/logstash/util/accessors.rb +6 -0
  18. data/lib/logstash/version.rb +1 -1
  19. data/locales/en.yml +5 -0
  20. data/logstash-core.gemspec +51 -0
  21. data/spec/core/conditionals_spec.rb +428 -0
  22. data/spec/core/config_mixin_spec.rb +99 -0
  23. data/spec/core/config_spec.rb +108 -0
  24. data/spec/core/environment_spec.rb +44 -0
  25. data/spec/core/event_spec.rb +473 -0
  26. data/spec/core/pipeline_spec.rb +198 -0
  27. data/spec/core/plugin_spec.rb +106 -0
  28. data/spec/core/runner_spec.rb +39 -0
  29. data/spec/core/timestamp_spec.rb +83 -0
  30. data/spec/filters/base_spec.rb +318 -0
  31. data/spec/inputs/base_spec.rb +13 -0
  32. data/spec/lib/logstash/bundler_spec.rb +120 -0
  33. data/spec/lib/logstash/java_integration_spec.rb +257 -0
  34. data/spec/logstash/agent_spec.rb +37 -0
  35. data/spec/outputs/base_spec.rb +47 -0
  36. data/spec/spec_helper.rb +1 -0
  37. data/spec/util/accessors_spec.rb +215 -0
  38. data/spec/util/charset_spec.rb +74 -0
  39. data/spec/util/fieldeval_spec.rb +96 -0
  40. data/spec/util/gemfile_spec.rb +212 -0
  41. data/spec/util/json_spec.rb +97 -0
  42. data/spec/util/plugin_version_spec.rb +48 -0
  43. data/spec/util/retryable_spec.rb +145 -0
  44. data/spec/util_spec.rb +34 -0
  45. metadata +96 -253
  46. data/lib/logstash-event.rb +0 -2
  47. data/lib/logstash.rb +0 -4
  48. data/lib/logstash/JRUBY-PR1448.rb +0 -32
  49. data/lib/logstash/bundler.rb +0 -124
  50. data/lib/logstash/gemfile.rb +0 -175
  51. data/lib/logstash/pluginmanager.rb +0 -17
  52. data/lib/logstash/pluginmanager/install.rb +0 -112
  53. data/lib/logstash/pluginmanager/list.rb +0 -38
  54. data/lib/logstash/pluginmanager/main.rb +0 -22
  55. data/lib/logstash/pluginmanager/maven_tools_patch.rb +0 -12
  56. data/lib/logstash/pluginmanager/uninstall.rb +0 -49
  57. data/lib/logstash/pluginmanager/update.rb +0 -50
  58. data/lib/logstash/pluginmanager/util.rb +0 -88
@@ -1,38 +0,0 @@
1
- require 'clamp'
2
- require 'logstash/namespace'
3
- require 'logstash/pluginmanager/util'
4
- require 'rubygems/spec_fetcher'
5
-
6
- class LogStash::PluginManager::List < Clamp::Command
7
-
8
- parameter "[PLUGIN]", "Part of plugin name to search for, leave empty for all plugins"
9
-
10
- option "--installed", :flag, "List only explicitly installed plugins using bin/plugin install ...", :default => false
11
- option "--verbose", :flag, "Also show plugin version number", :default => false
12
- option "--group", "NAME", "Filter plugins per group: input, output, filter or codec" do |arg|
13
- raise(ArgumentError, "should be one of: input, output, filter or codec") unless ['input', 'output', 'filter', 'codec'].include?(arg)
14
- arg
15
- end
16
-
17
- def execute
18
- Gem.configuration.verbose = false
19
-
20
- gemfile = LogStash::Gemfile.new(File.new(LogStash::Environment::GEMFILE_PATH, "r+")).load
21
-
22
- # start with all locally installed plugin gems regardless of the Gemfile content
23
- specs = LogStash::PluginManager.find_plugins_gem_specs
24
-
25
- # apply filters
26
- specs = specs.select{|spec| gemfile.find(spec.name)} if installed?
27
- specs = specs.select{|spec| spec.name =~ /#{plugin}/i} if plugin
28
- specs = specs.select{|spec| spec.metadata['logstash_group'] == group} if group
29
-
30
- raise(LogStash::PluginManager::Error, "No plugins found") if specs.empty?
31
-
32
- specs.sort_by{|spec| spec.name}.each do |spec|
33
- line = "#{spec.name}"
34
- line += " (#{spec.version})" if verbose?
35
- puts(line)
36
- end
37
- end
38
- end # class Logstash::PluginManager
@@ -1,22 +0,0 @@
1
- require "logstash/namespace"
2
- require "logstash/errors"
3
- require "logstash/pluginmanager/install"
4
- require "logstash/pluginmanager/uninstall"
5
- require "logstash/pluginmanager/list"
6
- require "logstash/pluginmanager/update"
7
- require "logstash/pluginmanager/util"
8
- require "logstash/pluginmanager/maven_tools_patch"
9
- require "clamp"
10
-
11
- module LogStash
12
- module PluginManager
13
- class Error < StandardError; end
14
-
15
- class Main < Clamp::Command
16
- subcommand "install", "Install a plugin", LogStash::PluginManager::Install
17
- subcommand "uninstall", "Uninstall a plugin", LogStash::PluginManager::Uninstall
18
- subcommand "update", "Install a plugin", LogStash::PluginManager::Update
19
- subcommand "list", "List all installed plugins", LogStash::PluginManager::List
20
- end
21
- end
22
- end
@@ -1,12 +0,0 @@
1
- # This adds the "repo" element to the jar-dependencies DSL
2
- # allowing a gemspec to require a jar that exists in a custom
3
- # maven repository
4
- # Example:
5
- # gemspec.requirements << "repo http://localhosty/repo"
6
- require 'maven/tools/dsl/project_gemspec'
7
- class Maven::Tools::DSL::ProjectGemspec
8
- def repo(url)
9
- @parent.repository(:id => url, :url => url)
10
- end
11
- end
12
-
@@ -1,49 +0,0 @@
1
- require "logstash/namespace"
2
- require "logstash/logging"
3
- require "logstash/errors"
4
- require "logstash/environment"
5
- require "logstash/pluginmanager/util"
6
- require "clamp"
7
-
8
- require "logstash/gemfile"
9
- require "logstash/bundler"
10
-
11
- class LogStash::PluginManager::Uninstall < Clamp::Command
12
- parameter "PLUGIN", "plugin name"
13
-
14
-
15
- def execute
16
- raise(LogStash::PluginManager::Error, "File #{LogStash::Environment::GEMFILE_PATH} does not exist or is not writable, aborting") unless File.writable?(LogStash::Environment::GEMFILE_PATH)
17
-
18
- gemfile = LogStash::Gemfile.new(File.new(LogStash::Environment::GEMFILE_PATH, "r+")).load
19
- # keep a copy of the gemset to revert on error
20
- original_gemset = gemfile.gemset.copy
21
-
22
- # make sure this is an installed plugin and present in Gemfile.
23
- # it is not possible to uninstall a dependency not listed in the Gemfile, for example a dependent codec
24
- raise(LogStash::PluginManager::Error, "This plugin has not been previously installed, aborting") unless LogStash::PluginManager.installed_plugin?(plugin, gemfile)
25
-
26
- # since we previously did a gemfile.find(plugin) there is no reason why
27
- # remove would not work (return nil) here
28
- if gemfile.remove(plugin)
29
- gemfile.save
30
-
31
- puts("Uninstalling #{plugin}")
32
-
33
- # any errors will be logged to $stderr by invoke_bundler!
34
- output, exception = LogStash::Bundler.invoke_bundler!(:clean => true)
35
-
36
- if ENV["DEBUG"]
37
- $stderr.puts(output)
38
- $stderr.puts("Error: #{exception.class}, #{exception.message}") if exception
39
- end
40
-
41
- if exception
42
- # revert to original Gemfile content
43
- gemfile.gemset = original_gemset
44
- gemfile.save
45
- raise(LogStash::PluginManager::Error, "Uninstall aborted")
46
- end
47
- end
48
- end
49
- end
@@ -1,50 +0,0 @@
1
- require 'clamp'
2
- require 'logstash/namespace'
3
- require 'logstash/pluginmanager/util'
4
- require 'jar-dependencies'
5
- require 'jar_install_post_install_hook'
6
- require 'file-dependencies/gem'
7
-
8
- require "logstash/gemfile"
9
- require "logstash/bundler"
10
-
11
- class LogStash::PluginManager::Update < Clamp::Command
12
- parameter "[PLUGIN] ...", "Plugin name(s) to upgrade to latest version"
13
-
14
- def execute
15
- gemfile = LogStash::Gemfile.new(File.new(LogStash::Environment::GEMFILE_PATH, "r+")).load
16
- # keep a copy of the gemset to revert on error
17
- original_gemset = gemfile.gemset.copy
18
-
19
- # create list of plugins to update
20
- plugins = unless plugin_list.empty?
21
- not_installed = plugin_list.find{|plugin| !LogStash::PluginManager.installed_plugin?(plugin, gemfile)}
22
- raise(LogStash::PluginManager::Error, "Plugin #{not_installed} has not been previously installed, aborting") if not_installed
23
- plugin_list
24
- else
25
- LogStash::PluginManager.all_installed_plugins_gem_specs(gemfile).map{|spec| spec.name}
26
- end
27
-
28
- # remove any version constrain from the Gemfile so the plugin(s) can be updated to latest version
29
- # calling update without requiremend will remove any previous requirements
30
- plugins.each{|plugin| gemfile.update(plugin)}
31
- gemfile.save
32
-
33
- puts("Updating " + plugins.join(", "))
34
-
35
- # any errors will be logged to $stderr by invoke_bundler!
36
- output, exception = LogStash::Bundler.invoke_bundler!(:update => plugins)
37
-
38
- if ENV["DEBUG"]
39
- $stderr.puts(output)
40
- $stderr.puts("Error: #{exception.class}, #{exception.message}") if exception
41
- end
42
-
43
- if exception
44
- # revert to original Gemfile content
45
- gemfile.gemset = original_gemset
46
- gemfile.save
47
- raise(LogStash::PluginManager::Error, "Update aborted")
48
- end
49
- end
50
- end
@@ -1,88 +0,0 @@
1
- module LogStash::PluginManager
2
-
3
- # check for valid logstash plugin gem name & version or .gem file, logs errors to $stdout
4
- # uses Rubygems API and will remotely validated agains the current Gem.sources
5
- # @param plugin [String] plugin name or .gem file path
6
- # @param version [String] gem version requirement string
7
- # @return [Boolean] true if valid logstash plugin gem name & version or a .gem file
8
- def self.logstash_plugin?(plugin, version = nil)
9
- if plugin_file?(plugin)
10
- begin
11
- return logstash_plugin_gem_spec?(plugin_file_spec(plugin))
12
- rescue => e
13
- $stderr.puts("Error reading plugin file #{plugin}, caused by #{e.class}")
14
- $stderr.puts(e.message) if ENV["DEBUG"]
15
- return false
16
- end
17
- else
18
- dep = Gem::Dependency.new(plugin, version || Gem::Requirement.default)
19
- specs, error = Gem::SpecFetcher.fetcher.spec_for_dependency(dep)
20
-
21
- # depending on version requirements, multiple specs can be returned in which case
22
- # we will grab the one with the highest version number
23
- if latest = specs.map(&:first).max_by(&:version)
24
- unless valid = logstash_plugin_gem_spec?(latest)
25
- $stderr.puts("#{plugin} is not a Logstash plugin")
26
- end
27
- return valid
28
- else
29
- $stderr.puts("Plugin #{plugin}" + (version ? " version #{version}" : "") + " does not exist")
30
- return false
31
- end
32
- end
33
- end
34
-
35
- # @param spec [Gem::Specification] plugin gem specification
36
- # @return [Boolean] true if this spec is for an installable logstash plugin
37
- def self.logstash_plugin_gem_spec?(spec)
38
- spec.metadata && spec.metadata["logstash_plugin"] == "true"
39
- end
40
-
41
- # @param path [String] path to .gem file
42
- # @return [Gem::Specification] .get file gem specification
43
- # @raise [Exception] Gem::Package::FormatError will be raised on invalid .gem file format, might be other exceptions too
44
- def self.plugin_file_spec(path)
45
- Gem::Package.new(path).spec
46
- end
47
-
48
- # @param plugin [String] the plugin name or the local path to a .gem file
49
- # @return [Boolean] true if the plugin is a local .gem file
50
- def self.plugin_file?(plugin)
51
- (plugin =~ /\.gem$/ && File.file?(plugin))
52
- end
53
-
54
- # retrieve gem specs for all or specified name valid logstash plugins locally installed
55
- # @param name [String] specific plugin name to find or nil for all plungins
56
- # @return [Array<Gem::Specification>] all local logstash plugin gem specs
57
- def self.find_plugins_gem_specs(name = nil)
58
- specs = name ? Gem::Specification.find_all_by_name(name) : Gem::Specification.find_all
59
- specs.select{|spec| logstash_plugin_gem_spec?(spec)}
60
- end
61
-
62
- # list of all locally installed plugins specs specified in the Gemfile.
63
- # note that an installed plugin dependecies like codecs will not be listed, only those
64
- # specifically listed in the Gemfile.
65
- # @param gemfile [LogStash::Gemfile] the gemfile to validate against
66
- # @return [Array<Gem::Specification>] list of plugin names
67
- def self.all_installed_plugins_gem_specs(gemfile)
68
- # we start form the installed gemspecs so we can verify the metadata for valid logstash plugin
69
- # then filter out those not included in the Gemfile
70
- find_plugins_gem_specs.select{|spec| !!gemfile.find(spec.name)}
71
- end
72
-
73
- # @param plugin [String] plugin name
74
- # @param gemfile [LogStash::Gemfile] the gemfile to validate against
75
- # @return [Boolean] true if the plugin is an installed logstash plugin and spefificed in the Gemfile
76
- def self.installed_plugin?(plugin, gemfile)
77
- !!gemfile.find(plugin) && find_plugins_gem_specs(plugin).any?
78
- end
79
-
80
- # @param plugin_list [Array] array of [plugin name, version] tuples
81
- # @return [Array] array of [plugin name, version, ...] tuples when duplciate names have been merged and non duplicate version requirements added
82
- def self.merge_duplicates(plugin_list)
83
-
84
- # quick & dirty naive dedup for now
85
- # TODO: properly merge versions requirements
86
- plugin_list.uniq(&:first)
87
- end
88
- end