logstash-core 1.5.0.rc3.snapshot6-java → 1.5.0.rc4-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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/logstash-core.rb +2 -0
  3. data/lib/logstash/agent.rb +0 -33
  4. data/lib/logstash/config/config_ast.rb +1 -1
  5. data/lib/logstash/environment.rb +8 -30
  6. data/lib/logstash/filters/base.rb +19 -0
  7. data/lib/logstash/namespace.rb +0 -1
  8. data/lib/logstash/runner.rb +3 -51
  9. data/lib/logstash/version.rb +1 -1
  10. data/logstash-core.gemspec +54 -0
  11. data/spec/core/conditionals_spec.rb +428 -0
  12. data/spec/core/config_mixin_spec.rb +99 -0
  13. data/spec/core/config_spec.rb +108 -0
  14. data/spec/core/environment_spec.rb +44 -0
  15. data/spec/core/event_spec.rb +468 -0
  16. data/spec/core/pipeline_spec.rb +198 -0
  17. data/spec/core/plugin_spec.rb +106 -0
  18. data/spec/core/runner_spec.rb +39 -0
  19. data/spec/core/timestamp_spec.rb +83 -0
  20. data/spec/filters/base_spec.rb +318 -0
  21. data/spec/inputs/base_spec.rb +13 -0
  22. data/spec/lib/logstash/bundler_spec.rb +120 -0
  23. data/spec/lib/logstash/java_integration_spec.rb +257 -0
  24. data/spec/logstash/agent_spec.rb +37 -0
  25. data/spec/outputs/base_spec.rb +47 -0
  26. data/spec/spec_helper.rb +1 -0
  27. data/spec/util/accessors_spec.rb +215 -0
  28. data/spec/util/charset_spec.rb +74 -0
  29. data/spec/util/fieldeval_spec.rb +96 -0
  30. data/spec/util/gemfile_spec.rb +212 -0
  31. data/spec/util/json_spec.rb +97 -0
  32. data/spec/util/plugin_version_spec.rb +48 -0
  33. data/spec/util_spec.rb +34 -0
  34. metadata +84 -160
  35. data/lib/logstash-event.rb +0 -2
  36. data/lib/logstash.rb +0 -4
  37. data/lib/logstash/bundler.rb +0 -156
  38. data/lib/logstash/gemfile.rb +0 -193
  39. data/lib/logstash/pluginmanager.rb +0 -17
  40. data/lib/logstash/pluginmanager/command.rb +0 -38
  41. data/lib/logstash/pluginmanager/install.rb +0 -141
  42. data/lib/logstash/pluginmanager/list.rb +0 -44
  43. data/lib/logstash/pluginmanager/main.rb +0 -21
  44. data/lib/logstash/pluginmanager/uninstall.rb +0 -43
  45. data/lib/logstash/pluginmanager/update.rb +0 -105
  46. data/lib/logstash/pluginmanager/util.rb +0 -89
@@ -1,44 +0,0 @@
1
- require 'clamp'
2
- require 'logstash/namespace'
3
- require 'logstash/pluginmanager/util'
4
- require 'logstash/pluginmanager/command'
5
- require "logstash/bundler"
6
- require 'rubygems/spec_fetcher'
7
-
8
- class LogStash::PluginManager::List < LogStash::PluginManager::Command
9
-
10
- parameter "[PLUGIN]", "Part of plugin name to search for, leave empty for all plugins"
11
-
12
- option "--installed", :flag, "List only explicitly installed plugins using bin/plugin install ...", :default => false
13
- option "--verbose", :flag, "Also show plugin version number", :default => false
14
- option "--group", "NAME", "Filter plugins per group: input, output, filter or codec" do |arg|
15
- raise(ArgumentError, "should be one of: input, output, filter or codec") unless ['input', 'output', 'filter', 'codec'].include?(arg)
16
- arg
17
- end
18
-
19
- def execute
20
- LogStash::Bundler.setup!
21
-
22
- signal_error("No plugins found") if filtered_specs.empty?
23
-
24
- filtered_specs.sort_by{|spec| spec.name}.each do |spec|
25
- line = "#{spec.name}"
26
- line += " (#{spec.version})" if verbose?
27
- puts(line)
28
- end
29
- end
30
-
31
- def filtered_specs
32
- @filtered_specs ||= begin
33
- # start with all locally installed plugin gems regardless of the Gemfile content
34
- specs = LogStash::PluginManager.find_plugins_gem_specs
35
-
36
- # apply filters
37
- specs = specs.select{|spec| gemfile.find(spec.name)} if installed?
38
- specs = specs.select{|spec| spec.name =~ /#{plugin}/i} if plugin
39
- specs = specs.select{|spec| spec.metadata['logstash_group'] == group} if group
40
-
41
- specs
42
- end
43
- end
44
- end # class Logstash::PluginManager
@@ -1,21 +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 "clamp"
9
-
10
- module LogStash
11
- module PluginManager
12
- class Error < StandardError; end
13
-
14
- class Main < Clamp::Command
15
- subcommand "install", "Install a plugin", LogStash::PluginManager::Install
16
- subcommand "uninstall", "Uninstall a plugin", LogStash::PluginManager::Uninstall
17
- subcommand "update", "Install a plugin", LogStash::PluginManager::Update
18
- subcommand "list", "List all installed plugins", LogStash::PluginManager::List
19
- end
20
- end
21
- end
@@ -1,43 +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 "logstash/pluginmanager/command"
7
- require "clamp"
8
-
9
- require "logstash/gemfile"
10
- require "logstash/bundler"
11
-
12
- class LogStash::PluginManager::Uninstall < LogStash::PluginManager::Command
13
- parameter "PLUGIN", "plugin name"
14
-
15
- def execute
16
- LogStash::Bundler.setup!
17
-
18
- signal_error("File #{LogStash::Environment::GEMFILE_PATH} does not exist or is not writable, aborting") unless File.writable?(LogStash::Environment::GEMFILE_PATH)
19
-
20
- # make sure this is an installed plugin and present in Gemfile.
21
- # it is not possible to uninstall a dependency not listed in the Gemfile, for example a dependent codec
22
- signal_error("This plugin has not been previously installed, aborting") unless LogStash::PluginManager.installed_plugin?(plugin, gemfile)
23
-
24
- # since we previously did a gemfile.find(plugin) there is no reason why
25
- # remove would not work (return nil) here
26
- if gemfile.remove(plugin)
27
- gemfile.save
28
-
29
- puts("Uninstalling #{plugin}")
30
-
31
- # any errors will be logged to $stderr by invoke_bundler!
32
- # output, exception = LogStash::Bundler.invoke_bundler!(:install => true, :clean => true)
33
- output = LogStash::Bundler.invoke_bundler!(:install => true)
34
-
35
- remove_unused_locally_installed_gems!
36
- end
37
- rescue => exception
38
- gemfile.restore!
39
- report_exception("Uninstall Aborted", exception)
40
- ensure
41
- display_bundler_output(output)
42
- end
43
- end
@@ -1,105 +0,0 @@
1
- require "clamp"
2
- require "logstash/namespace"
3
- require "logstash/pluginmanager/util"
4
- require "logstash/pluginmanager/command"
5
- require "jar-dependencies"
6
- require "jar_install_post_install_hook"
7
- require "file-dependencies/gem"
8
- require "logstash/gemfile"
9
- require "logstash/bundler"
10
-
11
- class LogStash::PluginManager::Update < LogStash::PluginManager::Command
12
- parameter "[PLUGIN] ...", "Plugin name(s) to upgrade to latest version", :attribute_name => :plugins_arg
13
-
14
- def execute
15
- local_gems = gemfile.locally_installed_gems
16
-
17
- if update_all? && !local_gems.empty?
18
- error_plugin_that_use_path!(local_gems)
19
- else
20
- plugins_with_path = plugins_arg & local_gems
21
- error_plugin_that_use_path!(plugins_with_path) if plugins_with_path.size > 0
22
- end
23
-
24
- update_gems!
25
- end
26
-
27
- private
28
- def error_plugin_that_use_path!(plugins)
29
- signal_error("Update is not supported for manually defined plugins or local .gem plugin installations: #{plugins.collect(&:name).join(",")}")
30
- end
31
-
32
- def update_all?
33
- plugins_arg.size == 0
34
- end
35
-
36
- def update_gems!
37
- # If any error is raise inside the block the Gemfile will restore a backup of the Gemfile
38
- previous_gem_specs_map = find_latest_gem_specs
39
-
40
- # remove any version constrain from the Gemfile so the plugin(s) can be updated to latest version
41
- # calling update without requiremend will remove any previous requirements
42
- plugins = plugins_to_update(previous_gem_specs_map)
43
- plugins
44
- .select { |plugin| gemfile.find(plugin) }
45
- .each { |plugin| gemfile.update(plugin) }
46
-
47
- # force a disk sync before running bundler
48
- gemfile.save
49
-
50
- puts("Updating " + plugins.join(", "))
51
-
52
- # any errors will be logged to $stderr by invoke_bundler!
53
- # Bundler cannot update and clean gems in one operation so we have to call the CLI twice.
54
- output = LogStash::Bundler.invoke_bundler!(:update => plugins)
55
- output = LogStash::Bundler.invoke_bundler!(:clean => true)
56
-
57
- display_updated_plugins(previous_gem_specs_map)
58
- rescue => exception
59
- gemfile.restore!
60
- report_exception("Updated Aborted", exception)
61
- ensure
62
- display_bundler_output(output)
63
- end
64
-
65
- # create list of plugins to update
66
- def plugins_to_update(previous_gem_specs_map)
67
- if update_all?
68
- previous_gem_specs_map.values.map{|spec| spec.name}
69
- else
70
- not_installed = plugins_arg.select{|plugin| !previous_gem_specs_map.has_key?(plugin.downcase)}
71
- signal_error("Plugin #{not_installed.join(', ')} is not installed so it cannot be updated, aborting") unless not_installed.empty?
72
- plugins_arg
73
- end
74
- end
75
-
76
- # We compare the before the update and after the update
77
- def display_updated_plugins(previous_gem_specs_map)
78
- update_count = 0
79
- find_latest_gem_specs.values.each do |spec|
80
- name = spec.name.downcase
81
- if previous_gem_specs_map.has_key?(name)
82
- if spec.version != previous_gem_specs_map[name].version
83
- puts("Updated #{spec.name} #{previous_gem_specs_map[name].version.to_s} to #{spec.version.to_s}")
84
- update_count += 1
85
- end
86
- else
87
- puts("Installed #{spec.name} #{spec.version.to_s}")
88
- update_count += 1
89
- end
90
- end
91
-
92
- puts("No plugin updated") if update_count.zero?
93
- end
94
-
95
- # retrieve only the latest spec for all locally installed plugins
96
- # @return [Hash] result hash {plugin_name.downcase => plugin_spec}
97
- def find_latest_gem_specs
98
- LogStash::Bundler.setup!
99
- LogStash::PluginManager.find_plugins_gem_specs.inject({}) do |result, spec|
100
- previous = result[spec.name.downcase]
101
- result[spec.name.downcase] = previous ? [previous, spec].max_by{|s| s.version} : spec
102
- result
103
- end
104
- end
105
- end
@@ -1,89 +0,0 @@
1
- require "rubygems/package"
2
-
3
- module LogStash::PluginManager
4
- # check for valid logstash plugin gem name & version or .gem file, logs errors to $stdout
5
- # uses Rubygems API and will remotely validated agains the current Gem.sources
6
- # @param plugin [String] plugin name or .gem file path
7
- # @param version [String] gem version requirement string
8
- # @return [Boolean] true if valid logstash plugin gem name & version or a .gem file
9
- def self.logstash_plugin?(plugin, version = nil)
10
- if plugin_file?(plugin)
11
- begin
12
- return logstash_plugin_gem_spec?(plugin_file_spec(plugin))
13
- rescue => e
14
- $stderr.puts("Error reading plugin file #{plugin}, caused by #{e.class}")
15
- $stderr.puts(e.message) if ENV["DEBUG"]
16
- return false
17
- end
18
- else
19
- dep = Gem::Dependency.new(plugin, version || Gem::Requirement.default)
20
- specs, error = Gem::SpecFetcher.fetcher.spec_for_dependency(dep)
21
-
22
- # depending on version requirements, multiple specs can be returned in which case
23
- # we will grab the one with the highest version number
24
- if latest = specs.map(&:first).max_by(&:version)
25
- unless valid = logstash_plugin_gem_spec?(latest)
26
- $stderr.puts("#{plugin} is not a Logstash plugin")
27
- end
28
- return valid
29
- else
30
- $stderr.puts("Plugin #{plugin}" + (version ? " version #{version}" : "") + " does not exist")
31
- return false
32
- end
33
- end
34
- end
35
-
36
- # @param spec [Gem::Specification] plugin gem specification
37
- # @return [Boolean] true if this spec is for an installable logstash plugin
38
- def self.logstash_plugin_gem_spec?(spec)
39
- spec.metadata && spec.metadata["logstash_plugin"] == "true"
40
- end
41
-
42
- # @param path [String] path to .gem file
43
- # @return [Gem::Specification] .get file gem specification
44
- # @raise [Exception] Gem::Package::FormatError will be raised on invalid .gem file format, might be other exceptions too
45
- def self.plugin_file_spec(path)
46
- Gem::Package.new(path).spec
47
- end
48
-
49
- # @param plugin [String] the plugin name or the local path to a .gem file
50
- # @return [Boolean] true if the plugin is a local .gem file
51
- def self.plugin_file?(plugin)
52
- (plugin =~ /\.gem$/ && File.file?(plugin))
53
- end
54
-
55
- # retrieve gem specs for all or specified name valid logstash plugins locally installed
56
- # @param name [String] specific plugin name to find or nil for all plungins
57
- # @return [Array<Gem::Specification>] all local logstash plugin gem specs
58
- def self.find_plugins_gem_specs(name = nil)
59
- specs = name ? Gem::Specification.find_all_by_name(name) : Gem::Specification.find_all
60
- specs.select{|spec| logstash_plugin_gem_spec?(spec)}
61
- end
62
-
63
- # list of all locally installed plugins specs specified in the Gemfile.
64
- # note that an installed plugin dependecies like codecs will not be listed, only those
65
- # specifically listed in the Gemfile.
66
- # @param gemfile [LogStash::Gemfile] the gemfile to validate against
67
- # @return [Array<Gem::Specification>] list of plugin specs
68
- def self.all_installed_plugins_gem_specs(gemfile)
69
- # we start form the installed gemspecs so we can verify the metadata for valid logstash plugin
70
- # then filter out those not included in the Gemfile
71
- find_plugins_gem_specs.select{|spec| !!gemfile.find(spec.name)}
72
- end
73
-
74
- # @param plugin [String] plugin name
75
- # @param gemfile [LogStash::Gemfile] the gemfile to validate against
76
- # @return [Boolean] true if the plugin is an installed logstash plugin and spefificed in the Gemfile
77
- def self.installed_plugin?(plugin, gemfile)
78
- !!gemfile.find(plugin) && find_plugins_gem_specs(plugin).any?
79
- end
80
-
81
- # @param plugin_list [Array] array of [plugin name, version] tuples
82
- # @return [Array] array of [plugin name, version, ...] tuples when duplciate names have been merged and non duplicate version requirements added
83
- def self.merge_duplicates(plugin_list)
84
-
85
- # quick & dirty naive dedup for now
86
- # TODO: properly merge versions requirements
87
- plugin_list.uniq(&:first)
88
- end
89
- end