Creating a New User Job

Jobs are defined in the Fabric Studio and can be saved to a project file and be deployed to the Fabric Server. A Job can be a Java function or a simple command.

How Do I Create a New User Job?

Step 1.

Go to the Project Tree > LU > Java > Category and right click New Function to display the Function Editor window.

Step 2.

Write the User Job function either from:

  • the Function Editor window.
  • IntelliJ IDE.
//writing into a file;

while (test<5 && !isAborted()){
    test=test+1;
    sleep(10000);
    inSecTime=test*10; // value returned by user job function
    FileWriter myWriter = new FileWriter("job_test4.txt",true);
    myWriter.write("Test Number: "+ test +"::->" + 10*test + " seconds have passed since ...");
    myWriter.close();
    }

Step 3.

Set the Function Type to the User Job value in the right panel. Once the job is triggered, the following Java user code writes a line into a new file job_test.txt every second until the counter test reaches the value 5. The output file is located in the Fabric Home directory.

Note that the loop control parameter (variable test) is defined as an input parameter of the User Job function, and that a second variable inSecTime is also defined as an output parameter. As such, its value is recorded in the argument field of the k2_jobs table in the k2system keyspace.

Name and save the function.

Step 4.

Go to the Project Tree > your LU > Jobs.

In the Job table, enter the values pertaining to the Job.

Method Where the name of the User Job Function defined in Step 4 is associated to the Job.
Unique Job Name Where the unique name for the Job service is defined and used for all manual or system operations executed on this job.
Execution Mode Can be set to either automatically or manually depending on whether the Job service is started from the Command Line or is managed by Fabric.
Active When checked, the Job is run and deployed.
Schedule Type

There are three schedule modes:

  • CRON, runs the Job according to the frequency described in the Cron description tab.
    For example, set the execution to: 30 0/2 8-18 5 3 ? 2021 at 30 seconds past the minute (30), every 2 minutes (0/2), between 08:00 and 18:59 (8-18), on day 5 of the month (5), only in March (3), only in year 2021 (2021).

  • TimeStamp, schedules a Job to run once on a given date and time. For example, set the execution to 2022-08-20 10:32:12.

  • Time Interval, schedules the Job to run at the frequency specified in the Execute Every field: For example, set the execution to: 10.11:22:33. the jobT runs every 10 days, 11 hours, 22 minutes, 33 seconds. If the time interval is set to 00:00:00, the job runs once automatically.

    It is important to note that if a scheduled job is started manually (before its scheduled occurence) then its next scheduled occurence will still start on time, unless the previous manual occurence of the job, is still running.

Affinity

Where the details of the node assigned to the job are entered. Affinity can be set using either one of the following options:

  • IP address of a Fabric node.
  • Data Center (DC) Name.
  • Node identifier, a logical identifier of Fabric node or a group of several Fabric nodes.

Example: AFFINITY=’DC1’, ’10.21.1.121’

Input parameters

Where the values of the input parameters are initialized. In this case the variable *test* is set to 0

(The output parameter value is recorded in the argument field of the k2_jobs table in the k2system keyspace.)

 

Step 5.

Right-click on the LU in the Project Tree, deploy and check for the file in the Fabric Home directory.

Previous

Creating a New User Job

Jobs are defined in the Fabric Studio and can be saved to a project file and be deployed to the Fabric Server. A Job can be a Java function or a simple command.

How Do I Create a New User Job?

Step 1.

Go to the Project Tree > LU > Java > Category and right click New Function to display the Function Editor window.

Step 2.

Write the User Job function either from:

  • the Function Editor window.
  • IntelliJ IDE.
//writing into a file;

while (test<5 && !isAborted()){
    test=test+1;
    sleep(10000);
    inSecTime=test*10; // value returned by user job function
    FileWriter myWriter = new FileWriter("job_test4.txt",true);
    myWriter.write("Test Number: "+ test +"::->" + 10*test + " seconds have passed since ...");
    myWriter.close();
    }

Step 3.

Set the Function Type to the User Job value in the right panel. Once the job is triggered, the following Java user code writes a line into a new file job_test.txt every second until the counter test reaches the value 5. The output file is located in the Fabric Home directory.

Note that the loop control parameter (variable test) is defined as an input parameter of the User Job function, and that a second variable inSecTime is also defined as an output parameter. As such, its value is recorded in the argument field of the k2_jobs table in the k2system keyspace.

Name and save the function.

Step 4.

Go to the Project Tree > your LU > Jobs.

In the Job table, enter the values pertaining to the Job.

Method Where the name of the User Job Function defined in Step 4 is associated to the Job.
Unique Job Name Where the unique name for the Job service is defined and used for all manual or system operations executed on this job.
Execution Mode Can be set to either automatically or manually depending on whether the Job service is started from the Command Line or is managed by Fabric.
Active When checked, the Job is run and deployed.
Schedule Type

There are three schedule modes:

  • CRON, runs the Job according to the frequency described in the Cron description tab.
    For example, set the execution to: 30 0/2 8-18 5 3 ? 2021 at 30 seconds past the minute (30), every 2 minutes (0/2), between 08:00 and 18:59 (8-18), on day 5 of the month (5), only in March (3), only in year 2021 (2021).

  • TimeStamp, schedules a Job to run once on a given date and time. For example, set the execution to 2022-08-20 10:32:12.

  • Time Interval, schedules the Job to run at the frequency specified in the Execute Every field: For example, set the execution to: 10.11:22:33. the jobT runs every 10 days, 11 hours, 22 minutes, 33 seconds. If the time interval is set to 00:00:00, the job runs once automatically.

    It is important to note that if a scheduled job is started manually (before its scheduled occurence) then its next scheduled occurence will still start on time, unless the previous manual occurence of the job, is still running.

Affinity

Where the details of the node assigned to the job are entered. Affinity can be set using either one of the following options:

  • IP address of a Fabric node.
  • Data Center (DC) Name.
  • Node identifier, a logical identifier of Fabric node or a group of several Fabric nodes.

Example: AFFINITY=’DC1’, ’10.21.1.121’

Input parameters

Where the values of the input parameters are initialized. In this case the variable *test* is set to 0

(The output parameter value is recorded in the argument field of the k2_jobs table in the k2system keyspace.)

 

Step 5.

Right-click on the LU in the Project Tree, deploy and check for the file in the Fabric Home directory.

Previous