@@ -33,7 +33,7 @@ class SpringInsight < JavaBuildpack::Component::BaseComponent
3333 # @param [Hash] context a collection of utilities used the component
3434 def initialize ( context )
3535 super ( context )
36- @version , @uri , @agent_id , @agent_pass = supports? ? find_insight_agent : [ nil , nil , nil , nil ]
36+ @version , @uri , @agent_transport = find_insight_agent if supports?
3737 end
3838
3939 # (see JavaBuildpack::Component::BaseComponent#detect)
@@ -45,8 +45,7 @@ def detect
4545 def compile
4646 JavaBuildpack ::Util ::Cache ::InternetAvailability . instance . available (
4747 true , 'The Spring Insight download location is always accessible' ) do
48- # TODO: AGENT_DOWNLOAD_URI_SUFFIX To be removed once the full path is included in VCAP_SERVICES see #58873498
49- download ( @version , @uri . chomp ( '/' ) + AGENT_DOWNLOAD_URI_SUFFIX ) { |file | expand file }
48+ download ( @version , @uri ) { |file | expand file }
5049 end
5150 end
5251
@@ -58,15 +57,11 @@ def release
5857 . add_system_property ( 'insight.logs' , logs_directory )
5958 . add_system_property ( 'aspectj.overweaving' , true )
6059 . add_system_property ( 'org.aspectj.tracing.factory' , 'default' )
61- . add_system_property ( 'insight.transport.type' , 'HTTP' )
62-
63- add_agent_configuration
6460 end
6561
6662 protected
6763
68- # The unique identifier of the component, incorporating the version of the dependency (e.g.
69- # +spring-insight=1.9.3+)
64+ # The unique identifier of the component, incorporating the version of the dependency)
7065 #
7166 # @param [String] version the version of the dependency
7267 # @return [String] the unique identifier of the component
@@ -76,24 +71,9 @@ def id(version)
7671
7772 private
7873
79- # TODO: To be removed once the full path is included in VCAP_SERVICES see issue 58873498
80- AGENT_DOWNLOAD_URI_SUFFIX = '/services/config/agent-download' . freeze
81-
82- FILTER = /insight/ . freeze
74+ FILTER = /p-insight/ . freeze
8375
84- private_constant :AGENT_DOWNLOAD_URI_SUFFIX , :FILTER
85-
86- def add_agent_configuration
87- @droplet . java_opts
88- . add_system_property ( 'agent.http.protocol' , 'http' )
89- . add_system_property ( 'agent.http.host' , URI ( @uri ) . host )
90- . add_system_property ( 'agent.http.port' , 80 )
91- . add_system_property ( 'agent.http.context.path' , 'insight' )
92- . add_system_property ( 'agent.http.username' , @agent_id )
93- . add_system_property ( 'agent.http.password' , @agent_pass )
94- . add_system_property ( 'agent.http.send.json' , false )
95- . add_system_property ( 'agent.http.use.proxy' , false )
96- end
76+ private_constant :FILTER
9777
9878 def expand ( file )
9979 with_timing "Expanding Spring Insight to #{ @droplet . sandbox . relative_path_from ( @droplet . root ) } " do
@@ -112,61 +92,58 @@ def unpack_agent_installer(root, file)
11292 FileUtils . mkdir_p ( agent_dir )
11393 shell "unzip -qq #{ file . path } -d #{ installer_dir } 2>&1"
11494 shell "unzip -qq #{ uber_agent_zip ( installer_dir ) } -d #{ agent_dir } 2>&1"
95+ move agent_dir ,
96+ installer_dir + 'answers.properties' ,
97+ installer_dir + 'agent.override.properties'
11598
11699 agent_dir
117100 end
118101
119102 def install_insight ( agent_dir )
120103 root = Pathname . glob ( agent_dir + 'springsource-insight-uber-agent-*' ) [ 0 ]
121104
122- init_container_libs root
123- init_insight_cloudfoundry_agent_plugin root
124105 init_insight root
106+ init_insight_properties agent_dir
125107 init_insight_agent_plugins root
126108 init_weaver root
127109 end
128110
129- def init_container_libs ( root )
130- move container_libs_directory ,
131- root + 'agents/common/insight-bootstrap-generic-*.jar' ,
132- root + 'agents/tomcat/7/lib/insight-bootstrap-tomcat-common-*.jar' ,
133- root + 'agents/tomcat/7/lib/insight-agent-*.jar'
134- end
135-
136111 def init_insight ( root )
137112 move insight_directory ,
138113 root + 'insight/collection-plugins' ,
139- root + 'insight/conf'
114+ root + 'insight/conf' ,
115+ root + 'insight/bootstrap' ,
116+ root + 'insight/extras'
140117 end
141118
142- def init_insight_agent_plugins ( root )
143- move insight_directory + 'agent-plugins' ,
144- root + 'transport/http/insight-agent-http-*.jar' ,
145- root + 'cloudfoundry/insight-agent-cloudfoundry-*.jar'
119+ def init_insight_properties ( root )
120+ move insight_directory ,
121+ root + 'agent.override.properties'
122+
123+ answers_properties = root + 'answers.properties'
124+ insight_properties = insight_directory + 'conf/insight.properties'
125+ system "cat #{ answers_properties } >> #{ insight_properties } "
146126 end
147127
148- def init_insight_cloudfoundry_agent_plugin ( root )
149- move container_libs_directory ,
150- root + 'cloudfoundry/cloudfoundry-runtime-*.jar'
128+ def init_insight_agent_plugins ( root )
129+ move insight_directory + 'agent-plugins' ,
130+ root + 'agents/tomcat/7/lib/insight-agent-*.jar'
131+ transport_jar = transport_plugin root
132+ move insight_directory + 'agent-plugins' , transport_jar
151133 end
152134
153135 def init_weaver ( root )
154136 move weaver_directory ,
155137 root + 'cloudfoundry/insight-weaver-*.jar'
156138 end
157139
158- def container_libs_directory
159- @droplet . root + '.spring-insight/container-libs'
160- end
161-
162140 def find_insight_agent
163141 service = @application . services . find_service FILTER
164- version = service [ 'label' ] . match ( /(.*)-(.*)/ ) [ 2 ]
165142 credentials = service [ 'credentials' ]
166- uri = credentials [ 'dashboard_url' ]
167- id = credentials [ 'agent_username ' ]
168- pass = credentials [ 'agent_password' ]
169- [ version , uri , id , pass ]
143+ version = credentials [ 'version' ] || '1.0.0'
144+ uri = credentials [ 'agent_download_url ' ]
145+ transport = credentials [ 'agent_transport' ] || 'rabbitmq'
146+ [ version , uri , transport ]
170147 end
171148
172149 def insight_directory
@@ -186,7 +163,7 @@ def move(destination, *globs)
186163 end
187164
188165 def supports?
189- @application . services . one_service? FILTER , 'dashboard_url ' , 'agent_username' , 'agent_password '
166+ @application . services . one_service? FILTER , 'agent_download_url ' , 'service_instance_id '
190167 end
191168
192169 def uber_agent_zip ( location )
@@ -203,6 +180,25 @@ def weaver_jar
203180 ( weaver_directory + 'insight-weaver-*.jar' ) . glob [ 0 ]
204181 end
205182
183+ def transport_plugin ( root )
184+ return root + 'transport/http/insight-agent-http-*.jar' if http_transport?
185+ return root + 'transport/rabbitmq/insight-agent-rabbitmq-*.jar' if rabbit_transport?
186+ ( root + 'transport/activemq/insight-agent-activemq-*.jar' ) if active_transport?
187+ end
188+
189+ def http_transport?
190+ @agent_transport . eql? 'http'
191+ end
192+
193+ def rabbit_transport?
194+ @agent_transport . eql? 'rabbitmq'
195+ end
196+
197+ def active_transport?
198+ @agent_transport . eql? 'activemq'
199+ end
200+
206201 end
202+
207203 end
208204end
0 commit comments