Spring Batch allow only one instance at time - spring-batch

I want to allow to run only 1 batch run at time. I tried to find it by using this code (from job listener):
Set<JobExecution> jobExecutions = jobExplorer.findRunningJobExecutions(jobExecution.getJobInstance().getJobName());
if (jobExecutions.size() > 1)
System.exit(2);
When I run 2 batches from different terminals this code doesn't work.
P.S. In dev environment I use HSQL.

Related

google cloud notebook instance run script not in startup

I have a notebook instance with a notebook file. I use the instance's startup script to run this notebook file using papermill.
I want the notebook file to be run only when I remotely start the instance, and not from google cloud console.
I'd like to know if one of these is possible, or if there's another solution:
1 - The script will detect that the instance was started from the dashboard.
2 - I will remove the startups script and use another script that can be run by a remote command.
3 - The shutdown script will remove the startup script.
Script definition is kept under /var/run/google.startup.script for the scenarios mentioned:
Seems complicated detect if the instance was started from the dashboard.
Is feasible to delete the startup script mentioned earlier, and run your own script remotely.
Delete the script.
Before to delete the scrip I suggest you to make a backup of it in case of any issue arises for delete it, also keep in mind that AI Platform Notebooks is a managed service, any admin configuration could cause potential issues in your instance, be careful when deleting or modifying the startup script.
My advise will be actually run a notebook via a Scheduler system, I posted here the multiple options: GCP run a prediction of a model every day

Why do Selenium tests behave different on different machines?

I couldn't find much information on Google regarding this topic. Below, I have provided three results from the same Selenium tests. Why am I getting different results when running the tests from different places?
INFO:
So our architecture: Bitbucket, Bamboo Stage 1 (Build, Deploy to QA), Bamboo Stage 2 (start Amazon EC2 instance "Test", run tests from Test against recently deployed QA)
Using Chrome Webdriver.
For all three of the variations I am using the same QA URL that our application is deployed on.
I am running all tests Parallelizable per fixture
The EC2 instance is running Windows Server 2012 R2 with the Chrome browser installed
I have made sure that the test solution has been properly deployed to the EC2 "test" instance. It is indeed the exact same solution and builds correctly.
First, Local:
Second, from EC2 Via SSM Script that invokes the tests:
Note that the PowerShell script calls the nunit3-console.exe just like it would be utilized in my third example using the command line.
Lastly, RDP in on EC2 and run tests from the command line:
This has me perplexed... Any reasons why Selenium is running different on different machines?
This really should be a comment, but I can't comment yet so...
I don't know enough about the application you are testing to say for sure, but this seems like something I've seen testing the application I'm working on.
I have seen two issues. First, Selenium is checking for the element before it's created. Sometimes it works and sometimes it fails, it just depends on how quickly the page loads when the test runs. There's no rhyme or reason to it. Second, the app I'm testing is pretty dumb. When you touch a field, enter data and move on to the next, it, effectively, posts all editable fields back to the database and refreshes all the fields. So, Selenium enters the value, moves to the next field and pops either a stale element error or can't find element error depending on when in the post/refresh cycle it attempts to interact with the element.
The solution I have found is moderately ugly, I tried the wait until, but because it's the same element name, it's already visible and is grabbed immediately which returns a stale element. As a result, the only thing that I have found is that by using explicit waits between calls, I can get it to run correctly consistently. Below is an example of what I have to do with the app I'm testing. (I am aware that I can condense the code, I am working within the style manual for my company)
Thread.Sleep(2000);
By nBaseLocator = By.XPath("//*[#id='attr_seq_1240']");
IWebElement baseRate = driver.FindElement(nBaseLocator);
baseRate.SendKeys(Keys.Home + xBaseRate + Keys.Tab);
If this doesn't help, please tell us more about the app and how it's functioning so we can help you find a solution.
#Florent B. Thank you!
EDIT: This ended up not working...
The tests are still running different when called remotely with a powershell script. But, the tests are running locally on both the ec2 instance and my machine correctly.
So the headless command switch allowed me to replicate my failed tests locally.
Next I found out that a headless chrome browser is used during the tests when running via script on an EC2 instance... That is automatic, so the tests where indeed running and the errors where valid.
Finally, I figured out that the screen size is indeed the culprit as it was stuck to a size of 600/400 (600/400?)
So after many tries, the only usable screen size option for Windows, C# and ChromeDriver 2.32 is to set your webDriver options when you initiate you driver:
ChromeOptions chromeOpt = new ChromeOptions();
chromeOpt.AddArguments("--headless");
chromeOpt.AddArgument("--window-size=1920,1080");
chromeOpt.AddArguments("--disable-gpu");
webDriver = new ChromeDriver(chromeOpt);
FINISH EDIT:
Just to update
Screen size is large enough.
Still attempting to solve the issue. Anyone else ran into this?
AWS SSM Command -> Powershell -> Run Selenium Tests with Start-Process -> Any test that requires an element fails because ElementNotFound or ElementNotVisible exceptions.
Using POM for tests. FindsBy filter in c# is not finding elements.
Running tests locally on EC2 run fine from cmd, powershell and Powershell ISE.
The tests do not work correctly when executing with the AWS SSM Command. Cannot find any resources to fix problem.

How to create JOB in AS400?

I'm new to AS400 DB2 , I have 3 procedures in AS400, now those procedure should be execute by calling single job in AS400.
Can you tell me please how to create a job and execute job in AS400 DB2 Mainframe ?
You're probably not using an AS/400 running OS/400; they have been obsolete for 10 years. You're probably using a POWER server running IBM i.
POWER servers are not mainframes, they are mid-range systems.
On the IBM i, a job is how the operating system organizes, tracks, and processes work. On other platforms, you'd call it a process.
Jobs are the basis of work management
When you sign onto a 5250 session, the system starts an "interactive job" to service your requests. You can't call procedures directly, but you can call a program that then calls the procedures.
There are plenty of common jobs tasks. Including the use of Submit Job (SBMJOB) command to submit a job to run in batch.
From what I understand, you want to run 3 programs in by invoking a single command. Is that it?
In OS/400 (haven't used it in over a decade) you put the commands for the programs into a CL source and compile it. Unlike .bat files on Windows, CL isn't going to run without compilation.
Refer to https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/rbam6/creat.htm for how to create a CL program.

preferred pattern for conditional execution of a Talend job

I have a Talend job (call it A) that I want to run when an Oracle stored procedure (not executed by Talend) has completed. I have an Oracle control table that I can check to see if the Oracle SP has finished.
I am imagining having my Talend job A run on a schedule - perhaps every 15 minutes - and the first thing that it would do is determine if A has already executed today. If it has already run today it would stop execution immediately. If it has not yet run today, it will check to see if the Oracle SP has completed, and if not, it will stop execution immediately. This should result in Talend job A only executing once a day, and only after the Oracle SP has completed.
Is there a more elegant way to accomplish this?
Thanks.
As you've stated in the comments, Oracle SP has a CronJob.
You should make a Talend Job (A) which will be executed shortly after the Oracle SP start. This would have an Iterate + tOracleInput-tJavaRow + tRunJob + tJava
Iterate (i<=80 && somevalue==1 --> tOracleInput - row1 - tJava --
--IF--> row1.field.equals("true") --> tJava i = 101; --> tRunJob(JobB)
--IF--> !row1.field.equals("true") --> tJava Thread.Sleep(15*60*1000);
This way when you execute the JobB you'll exit from the loop. Also your Talend Job will run once a day, and does the calculation once a day. I know it seems to be a little dirty but it will work.
Having i set to 80 you'll end up with 81 trys thats 20hour 15min for the worst case not counting the query runtime.
Thread.Sleep accepts miliseconds thats why you need to multiply by 1000 to get the seconds and 60 to get the minutes
You can also think below options
1) export/build your talend job (A) as shell/batch file and execute it via same unix crontab job which executes your SP. You have to set dependency may be based on exit code of SP job.
OR
2) you can run your SP from talend job either using tOracleSP or even you can run your unix shell if any existing using tSystem and onSubJobOk run your talend job (A).

How do I RDP simultaneously and run same scheduled task in parallel in 2 different sessions?

I have created a scheduled task with my userid and would like to run the same task in multiple sessions. What I would like to do is, I will do multiple RDP to the server where I have created the task, and run multiple instances of the task.
I can run the task perfectly, but, the problem I am facing is, the GUI that is opened through the task always opens in the first RDP session (screen).
The task opens QTP and runs a test. As there can be only one QTP that can run in a single session, I need to run multiple instances in multiple sessions.
As I am having problem with QTP RPC while trying to open from a .Net web application, I solved the problem by creating scheduled tasks through the web application, that in turn opens QTP and runs the test.
Now I am stuck, because although I can run QTP, I cannot run multiple instances.
Please help.
Run the task as a different user. Multiple tasks need multiple users. Works on 2003. I'm trying to get it to work on 2000 server.