I'm writing a plugin which implements the ILaunchConfigurationDelegate.
I have to override this method: launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor);
Can I attach a TextConsole to it like for the ones in the JavaApplication launch type when writing with System.out.println()?
I would like to have that in order that my launch has the same lifecycle management for its console.
Essentially my ILaunchConfiguration type is a container which holds all possible other ILaunchConfiguration types. When launching my launch container I want to log the behaviour of the others which start in a sequence. This logging would be ideal in a TextConsole. Example: 'Hello World started.' 'Hello World terminated', 'Pi approximator started' ... etc.
AFAIK, there are no extra steps necessary to redirect std in/out to the Eclipse console. The Common tab of every launch configuration type has an Allocate console option that provides this feature if enabled.
If your launch configuration type does not provide the CommonTab, you can set the IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE attribute of your ILaunchConfiguration to true.
For the container launch, you can simply allocate a TextConsole to write the log messages to. The debug/launch framework attaches consoles to IProcess instances and this won't help here but you may want to look to ProcessConsole and ProcessConsoleManager to adopt the relevant part to opening and discarding the console.
Alternatively, you could investigate if setting the ATTR_CAPTURE_IN_CONSOLE of the container launch to true and creating a dummy IProcess that satisfies the requirements of the ProcessConsoleManager wrt to consoles.
Related
in spring-integretion project,i have a hot folder that detects when a csv is placed in a folder and do some extra stuff, i have a inbound-channel-adapter connected with a channel.
inbound-channel-adapter -> channel.
detects when a csv its placed receive the mns its connected with
a service-activator
what i what to do its test only that the channel its receiving the mns when a file its created
i am using this tutorial
https://www.javacodegeeks.com/2013/05/spring-integration-file-polling-and-tests.html
its very useful, but i can create the context
Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener#57a4d5ee] to prepare test instance [proyect.integration.hotFolderTest#5af5def9]
java.lang.IllegalStateException: Failed to load ApplicationContext
You need to show more stack trace on the matter, because right now it isn't clear what is your real issue.
Also would be great to share some code what you have so far and what you would like to do in the test case.
To verify a message presence in the channel you can configure a ChannelInterceptor and implement its preSend().
However we also suggest something like #SpringIntegrationTest with the MockIntegration features. That way you can replace your real service activator with some MockIntegration.mockMessageHandler() and perform verification on it.
You would need to configure a noAutoStartup on the mentioned annotation do not poll directory until you prepare your mock and call a this.mockIntegrationContext.substituteMessageHandlerFor().
See more info in the Reference Manual: https://docs.spring.io/spring-integration/docs/current/reference/html/testing.html#test-context
The problem:
I want to run Selenium Grid on AWS and would like to use their dynamic scaling. On scale down, it will just terminate an instance... which mean that a node can disappear just like that. Not the behaviour I would like, but using scripts or lifecycle hooks, I can try and make sure that any sessions on the node is not active before it is terminated.
Seems like I can hit this API to disconnect the node from the hub: http://NODE-IP:5555/selenium-server/driver/?cmd=shutDownSeleniumServer
Ideally, I need to find an API to the node directly to gather data of session activity.
Alternatives? Sessions logs?
Note:
This answer is valid only for Selenium 3.x series (3.14.1 which is as of today the last of the builds in Selenium 3 series). Selenium 4 grid architecture is a complete different one and as such this answer will not necessarily be relevant for Selenium 4 grid (Its yet to be released).
Couple of things. What you are asking for sounds like you need a sort of self healing mechanism. This is not available in the plain vanilla selenium grid flavor.
Selenium node, doesn't have the capability to track sessions that are running within it.
You need to build all of this at the Selenium Hub (which is where all this information resides in).
On a high level, you would need to do the following
Build a custom proxy by extending org.openqa.grid.selenium.proxy.DefaultRemoteProxy which would have the following capabilities:
Add an API which when used would mark the proxy as quiesced (meaning the node has been marked for maintenance and will no longer accept any new session requests)
Override getNewSession(Map<String, Object> requestedCapability) such that it first checks if a node is not quiesced and only then facilitate a new session.
Build a custom servlet which when invoked can do the following:
Given a node it can use the API built via 1.1 and mark a node as quiesced
would return back the list of nodes that don't have any sessions running in them. If you build your servlet by extending org.openqa.grid.web.servlet.RegistryBasedServlet, within your servlet you should be able to get the list of free node urls by doing something like below
List<RemoteProxy> freeProxies =
StreamSupport.stream(getRegistry().getAllProxies().spliterator(), false)
.filter(remoteProxy -> !remoteProxy.isBusy())
.collect(Collectors.toList());
List<URL> urls =
freeProxies.stream().map(RemoteProxy::getRemoteHost).collect(Collectors.toList());
Now that we have the custom Hub which is now enabled with functionality to do this cleanup, you could now first invoke the 2.1 end-point to mark nodes to be shutdown and then keep polling 2.2 end-point to retrieve all the IP and Port combinations for the nodes that are no longer supporting any test session and then invoke http://NODE-IP:5555/selenium-server/driver/?cmd=shutDownSeleniumServer on them.
That on a high level can do what you are looking for.
Some useful links which can help you get oriented on this (All of the provided links are blogs that I wrote at various points in time).
Self healing grid - https://rationaleemotions.wordpress.com/2013/01/28/building-a-self-maintaining-grid-environment/
Building a custom proxy - https://rationaleemotions.github.io/gridopadesham/CUSTOM_PROXY.html
Building a custom servlet for the hub - https://rationaleemotions.github.io/gridopadesham/CUSTOM_SERVLETS.html
I've followed this tutorial and when setting up validation layers the author says we have to setup debug callbacks so logs can be printed in stdout.
I didn't set them up and yet the application is printing various error messages in my terminal : Swapchain(ERROR): object 0x1cdd2d0 type: 1 location: 292 msgCode: 3: VkDestroyInstance() called before all of its associated VkSurfaceKHRs were destroyed for instance, when omitting the call to vkDestroySurfaceKHR.
I'm using VK_LAYER_LUNARG_standard_validation, and no particular extension (only VK_KHR_surface and VK_KHR_xcb_surface).
Is this expected behaviour?
The default logging behavior for the validation layers was changed back around June 1 because people wanted the messages to go to stdout without having to provide a callback or putting a vk_layer_settings.txt in the application's directory. The tutorial website might be out of date in this area.
If this is unwanted behavior, the easiest way to change it is to get a copy of vk_layer_settings.txt (shipped in SDK) and edit it to change the behavior to what you want, and then place it in what is the current directory when the application starts.
As an alternative, you can also code a debug callback.
For more info, please see the layer docs on the LunarXchange website.
Hi could you please let me know the session filter setting to be added in jprofiler to prevent tracing of jdk internal calls?
Internal calls in the java.* packages are not measured by JProfiler in any case, regardless of your filter settings.
If you define "inclusive" filters that define the profiled classes, then all other packages are not profiled.
Note that the first call from a profiled class into a non-profiled class is always shown in the call tree, it's just the further internal calls that are not measured.
Is it possible to write a plugin for Glimpse's existing SQL tab?
I'm trying to log my SQL queries and the currently available extensions don't support our in-house SQL libary. I have written a custom plugin which logs what I want, but it has limited functionality and it doesn't integrate with the existing SQL tab.
Currently, I'm logging to my custom plugin using a single helper method inside my DAL's base class. This function looks takes the SqlCommand and Duration in order to show data on my custom tab:
// simplified example:
Stopwatch sw = Stopwatch.StartNew();
sqlCommand.Connection = sqlConnection;
sqlConnection.Open();
object result = sqlCommand.ExecuteScalar();
sqlConnection.Close();
sw.Stop();
long duration = sw.ElapsedMilliseconds;
LogSqlActivity(sqlCommand, null, duration);
This works well on my 'custom' tab but unfortunately means I don't get metrics shown on Glimpse's HUD:
Is there a way I can provide Glimpse directly with the info it needs (in terms of method names, and parameters) so it displays natively on the SQL tab?
The following advise is based on the fact that you can't use DbProviderFactory and you can't use a proxied SqlCommand, etc.
The data that appears in the "out-of-the-box" SQL tab is based on messages of given types been published through our internal Message Broker (see below on information on this). Because of the above limitations in your case, to get things lighting up correctly (i.e. your data showing up in HUD and the SQL tab), you will need to simulate the work that we do under the covers when we publish these messages. This shouldn't be that difficult and once done, should just work moving forward.
If you have a look at the various proxies we have here you will be above to see what messages we publish in what circumstances. Here are some highlights:
DbCommand
Log command start - here
Log command error - here
Log command end - here
DbConnection:
Log connection open - here
Log connection closed - here
DbTransaction
Log Started - here
Log committed - here
Log rollback - here
Other
Command row count here - Glimpses calculates this at the DbDataReader level but you could do it elsewhere as well
Now that you have an idea of what messages we are expecting and how we generate them, as long as you pass in the right data when you publish those messages, everything should just light up - if you are interested here is the code that looks for the messages that you will be publishing.
Message Broker: If you at the GlimpseConfiguration here you will see how to access the Broker. This can be done statically if needed (as we do here). From here you can publish the messages you need.
Helpers: For generating some of the above messages, you can use the helpers inside the Support class here. I would have shifted all the code for publishing the actual messages to this class, but I didn't think there would be too many people doing what you are doing.
Update 1
Starting point: With the above approach you shouldn't need to write your own plugin. You should just be able to access the broker GlimpseConfiguration.GetConfiguredMessageBroker() (make sure you check if its null, which it is if Glimpse is turned off, etc) and publish your messages.
I would imagine that you would put the inspection that leverages the broker and published the messages, where ever you have knowledge of the information that needs to be collected (i.e. inside your custom lib). Normally this would require references inside your lib to glimpse (which you may not want), so to protect against this, from your lib, you would call a proxy (which could be another VS proj) that has the glimpse dependency. Hence your ado lib only has references to your own code.
To get your toes wet, try just publishing a couple of fake connection and command messages. Assuming the broker you get from GlimpseConfiguration.GetConfiguredMessageBroker() isn't null, these should just show up. Then you can work towards getting real data into it from your lib.
Update 2
Obsolete Broker Access
Its marked as obsolete because its going to change in v2. You will still be able to do what you need to do, but the way of accessing the broker has changed. For what you currently need to do this is ok.
Sometimes null
As you have found this is really dependent on where in the page lifecycle you are currently at. To get around this, I would probably change my original recommendation a little.
In the code where you are currently creating messages and pushing them to the message bus, try putting them into HttpContext.Current.Items. If you haven't used it before, this is a store which asp.net provides out of the box which lasts the lifetime of a given request. You could have a list that you put in there, still create the message objects that you are doing, but put them into that list instead of pushing them through the broker.
Then, create a HttpModule (its really simple to do) which taps into the PostLogRequest event. Within this handler, you would pull the list out of the context, iterate through it and push the message into the message broker (accessing the same way you have been).