How to dynamically pass filename to tFTPRename in Talend? - java

I currently have a job that works like this:
tPrejob-->tOracleConnection1--->tOracleConnection2--->tSetGlobalVar1(timestamp)--->tRunjob(runs prejob to gather file from FTP)
Then there is a tPostjob that is supposed to rename the processed file on the FTP server.
tPostjob--->tFTPRename
It should be renaming the file with "File Processed On " + ((String)globalMap.get("timestamp")) + "This is where I would put the orginal file name"
If I put a standard filename into the Filemask then it will run correctly, however if I try to make the filemask dynamic by passing the filename into it through globalMap.get then I get the Error:
"Exception in component tFTPRename_1 java.lang.NullPointerException"
I've tried several methods for passing the file name into the tFTPRename component, but none are working.
I'm currently capturing the file name in the subjob and outputting it to a txt file and then using tFileInputFullRow on the main job to create that variable. I tried passing this into a tSetGlobalVar and then adding it into the filemask as ((String)globalMap.get("FileName")), but had no luck.
I also tried several methods on the internet, but none of them worked, so I wasn't sure if it was me or if it has something to do with tFTPRename capabilities.
Main Job:
PreJob:
tFTPRename Component:
tFileInputFullRow:

It sounds like you're using the globalMap wrong at some point which would certainly explain the null pointer exception as the globalMap variable doesn't appear to have been set.
Typically the tSetGlobalVar component is for setting static or run time generated variables into the globalMap and I don't think you can actually pass data into it that it can then directly use and push to the globalMap. Your datetime stamp is a good use of the component but you'll need to either use a tFlowToIterate component or use a tJava(Row) component to force the data into the globalMap using something like:
globalMap.put("fileName",inputrow.fileName);
Looking at your previous question then you should have the name of the file from the FTP in the job you are calling in your pre job. Typically here you would be able to then run that as part of the main flow into a tBufferOutput component and then read the data directly into the parent job (simply connect a main flow connector from the tRunJob component to the next component you want to process the data flow and don't forget to give the tRunJob component the same schema as your child job's tBufferOutput).
However, you have a complication here in that you have already used the buffer to capture all of the iterables from the tFTPList component so you're right in the fact that you need to go to a temporary flat file or database to push the state back to the parent job.
From here though you should be able to read in the flat file or database table that contains the field name in your parent job and then run for ease you can just connect this to a tFlowToIterate component which will then store that data in the globalMap (you should have 1 row and 1 column of data here so it's a single variable).
Here's a basic example of running some hard coded data in a tFixedFlowInput to a tFlowToIterate to get it into the globalMap and then retrieve it again with another tFixedFlowInput component:
Once the data is in the tFlowToIterate component then you can easily call it with globalMap.get(rowName.schemaColumnName) or by hitting ctrl+space and selecting it under the tFlowToIterate component:

Related

JMeter JSR233 result to dashboard

I have a JMeter test that insert an input via an HTTP call to an asynchronous java-service and then collects an exposed metric on another java-service via a groovy script.
The script then saves the collected metric as a JMeter variable to be reviewed as a performance metric.
I would like to publish this value inside the JMeter -generated dashboard but I can't find a way to save this variable as a JMeter output.
Is there a way? seems JMeter is primarily aimed to test HTTP synchronous services but it's capable of doing such collection of data.
You can use variable(s) in custom graph definitions:
You can graph any sample_variable in CSV over time, you can customize your graphs by settings their properties in the user.properties file.
They must use the id prefix custom_:
jmeter.reportgenerator.graph.custom_<your_graph_name_id>.property.<your_option_name>
To specify that this graph is a customized one :
jmeter.reportgenerator.graph.custom_<your_graph_name_id>.classname=org.apache.jmeter.report.processor.graph.impl.CustomGraphConsumer
Here is an example of a custom graph configuration that graphs the variable ts-hit:
jmeter.reportgenerator.graph.custom_testGraph.classname=org.apache.jmeter.report.processor.graph.impl.CustomGraphConsumer
jmeter.reportgenerator.graph.custom_testGraph.title=Chunk Hit
jmeter.reportgenerator.graph.custom_testGraph.property.set_Y_Axis=Number of Hits
jmeter.reportgenerator.graph.custom_testGraph.set_X_Axis=Over Time
jmeter.reportgenerator.graph.custom_testGraph.property.set_granularity=60000
jmeter.reportgenerator.graph.custom_testGraph.property.set_Sample_Variable_Name=ts-hit
jmeter.reportgenerator.graph.custom_testGraph.property.set_Content_Message=Number of Hits :
Declare the JMeter Variable you're saving in the JSR223 script as a Sample Variable, in order to do this add the next line to user.properties file:
sample_variables=foo
Then you can configure your custom chart like:
jmeter.reportgenerator.graph.custom_testGraph.classname=org.apache.jmeter.report.processor.graph.impl.CustomGraphConsumer
jmeter.reportgenerator.graph.custom_testGraph.title=Your custom chart title
jmeter.reportgenerator.graph.custom_testGraph.property.set_Y_Axis=Your Y axis name
jmeter.reportgenerator.graph.custom_testGraph.set_X_Axis=Over Time
jmeter.reportgenerator.graph.custom_testGraph.property.set_granularity=60000
jmeter.reportgenerator.graph.custom_testGraph.property.set_Sample_Variable_Name=foo
jmeter.reportgenerator.graph.custom_testGraph.property.set_Content_Message=Your custom content message
replace foo with the actual JMeter Variable name of your choice and next time you generate HTML reporting dashboard you should see your variable values plotted over time
More information:
Reporting configuration
Apache JMeter Properties Customization Guide

Netlogo Api Controller - Get Table View

I am using Netlogo Api Controller With spring boot
this my code (i got it from this link )
HeadlessWorkspace workspace = HeadlessWorkspace.newInstance();
try {
workspace.open("models/Residential_Solar_PV_Adoption.nlogo",true);
workspace.command("set number-of-residences 900");
workspace.command("set %-similar-wanted 7");
workspace.command("set count-years-simulated 14");
workspace.command("set number-of-residences 500");
workspace.command("set carbon-tax 13.7");
workspace.command("setup");
workspace.command("repeat 10 [ go ]");
workspace.command("reset-ticks");
workspace.dispose();
workspace.dispose();
}
catch(Exception ex) {
ex.printStackTrace();
}
i got this result in the console:
But I want to get the table view and save to database. Which command can I use to get the table view ?
Table view:
any help please ?
If you can clarify why you're trying to generate the data this way, I or others might be able to give better advice.
There is no single NetLogo command or NetLogo API method to generate that table, you have to use BehaviorSpace to get it. Here are some options, listed in rough order of simplest to hardest.
Option 1
If possible, I'd recommend just running BehaviorSpace experiments from the command line to generate your table. This will get you exactly the same output you're looking for. You can find information on how to do that in the NetLogo manual's BehaviorSpace guide. If necessary, you can run NetLogo headless from the command line from within a Java program, just look for resources on calling out to external programs from Java, maybe with ProcessBuilder.
If you're running from within Java in order to setup and change the parameters of your BehaviorSpace experiments in a way that you cannot do from within the program, you could instead generate experiment XML files in Java to pass to NetLogo at the command line. See the docs on the XML format.
Option 2
You can recreate the contents of the table using the CSV extension in your model and adding a few more commands to generate the data. This will not create the exact same table, but it will get your data output in a computer and human readable format.
In pure NetLogo code, you'd want something like the below. Note that you can control more of the behavior (like file names or the desired variables) by running other pre-experiment commands before running setup or go in your Java code. You could also run the CSV-specific file code from Java using the controlling API and leave the model unchanged, but you'll need to write your own NetLogo code version of the csv:to-row primitive.
globals [
;; your model globals here
output-variables
]
to setup
clear-all
;;; your model setup code here
file-open "my-output.csv"
; the given variables should be valid reporters for the NetLogo model
set output-variables [ "ticks" "current-price" "number-of-residences" "count-years-simulated" "solar-PV-cost" "%-lows" "k" ]
file-print csv:to-row output-variables
reset-ticks
end
to go
;;; the rest of your model code here
file-print csv:to-row map [ v -> runresult v ] output-variables
file-flush
tick
end
Option 3
If you really need to reproduce the BehaviorSpace table export exactly, you can try to run a BehaviorSpace experiment directly from Java. The table is generated by this code but as you can see it's tied in with the LabProtocol class, meaning you'll have to setup and run your model through BehaviorSpace instead of just step-by-step using a workspace as you've done in your sample code.
A good example of this might be the Main.scala object, which extracts some experiment settings from the expected command-line arguments, and then uses them with the lab.run() method to run the BehaviorSpace experiment and generate the output. That's Scala code and not Java, but hopefully it isn't too hard to translate. You'd similarly have to setup an org.nlogo.nvm.LabInterface.Settings instance and pass that off to a HeadlessWorkspace.newLab.run() to get things going.

Table doesn't exists in Liferay 6

I have defined a data table and associated objects in Liferay 6, but when I run the code it says the table doesn't exists, and it's true. The code runs fine when I create the table by hand just copy-pasting the create table from the model implementation, but I expected the table to be created when deploying.
The user has all the privileges needed to create it.
What I'm missing?
I face the same problem. and #urvish is correct you have to change build number in
service properties file.
problem
When multiple developers working on portlet that uses servicebuilder
will give below exception “Build namespace has build number which is
newer than “. When developer commits service.properties file and that
deployed on other developer machine then it will throw below
exception
Best Practice: To avoid these kind of errors, follow these:
create service-ext.properties file at the same locaiton of service.properties
add build.number={higher-value or same value in exception)
Deploy portlet again
.
Check values of build.namespace in service.properties file and value of
select buildNumber from servicecomponent where buildNamespace = <<build.namespace from service.properties>>
Now the buildNumber return from query must be lesser than value of build.number propert in service.properties. If it is not then just set the value of build.number to 9999.
Sometimes due to mismatch, changes are not applied to database.

How to get vm creation time from the machine's properties

I'm using vijava (5.1) to fetch data from a vCenter about virtual machines.
For that matter I'm using a filter with some properties (for example, guest.hostName, runtime.powerState etc.).
I need to get the creation time for these virtual machines and from what I saw, this info is available in the event logs of the vCenter.
Is there a way to get this info part of the virtual machine's properties?
I searched this info using the vSphere-Client and I didn't - so I guess the only place is from the event logs - but just to be sure, is that the only way?
Thanks
It is hard to get creation time of virtual machine using vijava api. However you can get other below informations from VirtualMachineConfigInfo.
changeVersion : The changeVersion is a unique identifier for a given version of the configuration. Each change to the configuration updates this value. This is typically implemented as an ever increasing count or a time-stamp. However, a client should always treat this as an opaque string.
modified : Last time a virtual machine's configuration was modified.
Folder rootFolder = serviceInstance.getRootFolder();
InventoryNavigator inventoryNavigator = new InventoryNavigator(rootFolder);
vm = (VirtualMachine) inventoryNavigator.searchManagedEntity(VirtualMachine.class.getSimpleName(), vmName);
VirtualMachineConfigInfo vmConfig = vm.getConfig();
System.out.println(vmConfig.getChangeVersion);
image for information in virtualMachineConfigInfo object
Unless you set the creation time as an extra config property then the event log is the only way I know of. If you want to go the extra config route I created a sample that shows how to use them that is part of the pyvmomi-community-samples project.

Genexus Ev2 Stored procedure

I'm trying to call a stored procedure on my iSeries System (RPG program) but I'm not able to activate the corresponding menu under "tools"->"Java Generator".
The RPG program that I want to call (we'll name it RPG00) has 5 input parameters and 1 output value.
I performed the following operations:
Create an "external object" (type: stored procedure) whose name is "RPG00"
Create a method named "RPG00" as well in the external object above and set the "external name" property to "RPG00"
Create a Web Panel with a variable &test (type: external object RPG00) and call it with the right parameters
Change the following settings in iSeries datastore configuration:
"access technology to set" --> JDBC
"list of external stored procedure" --> RPG00
At this point if i try to build the KB, it ends up always in error. In the project folder i can't find the "crtjdccalls.java" file and the corresponding "class" file that stores the instructions for the stored procedure..
What's going wrong? Any idea? Any suggestion?
The appropriate element in the "Java generator" menu never appears!!
My Configuration:
Gx Ev2 U5
Environment: Web\Java
DB: iSeries 6.1
I think you forgot set the data store property (JDBC) 'Library list' with the name of the library in which the RPG progrma RPG00 is found.
Check this and make a rebuild all.
Regards, Luis.
Thanks to the Genuxs development team I found a solution!
The problem is related to the way parameters are passed to the stored procedure.
REMEBER:
You can't use SDT elements as input parameters
You can't use direct values as input parameters
YOU CAN USE ONLY VARIABLES!!!
E.G.
SDT.value1, SDT.value2
&variable1 = SDT.value1
&variable2 = SDT.value2
&RPG00.RPG00(SDT.value1, SDT.value2, ecc) --> ERROR
&RPG00.RPG00(&variable1, XXX, ecc) --> ERROR where XXX is for example an integer value
&RPG00.RPG00(&variable1, &variable2, ecc) --> ONLY VARIABLES WORK FINE!!
Hope this help someone else

Categories