CoordinatorClient Guide For Developer

Content

  1. Introduction
    1. JDK,classpath
    2. Client method
    3. Jar file
  2. Function
    1. Client
    2. Operation list
    3. Proxy
  3. API
    1. Pipeline API
    2. Client JavaDoc (API)
  4. HTTPS Communication
    1. Set server
    2. Set client
    3. Execution sample

Introduction

CoordinatorClient is a client develop library, and it make it possible to use the pipeline service from any application.

JDK, Class

To run at the client side, it's necessary to prepare the environment which is JRE 1.5 or later. The essential library is

  • coordinatorclient.jar
  • .
Please run it through a classpath in the library.

Client method list

You can do the below operations at a client side. Please refer to JavaDoc for more details.

jar files

They are in the API kit. Please unzip the asteria-client-coordinatorclient-0.0.3.zip to get Jar files.

apikit-0.0.3.zip
    /coordinatorclient
       asteria-client-coordinatorclient-0.0.3.zip

Functions

Client

CoordinatorClient is a client class for communicating with the pipeline service. You can do many operations by creating the class and accessing to it.

// The client side connected to host:localhost , port: 25080
CoordinatorClient client = new CoordinatorClient() ;

// The client side connected to host:localhost and the specified port.
client = new CoordinatorClient( 25080 ) ;

// The client side connected to the specified host, port :25080
client = new CoordinatorClient( "192.168.5.99" ) ;

// The client side connected to the specified host and port.
client = new CoordinatorClient( "192.168.5.99" , 25080 ) ;

// The client side connected to the specified host and port by https.
client = new CoordinatorClient( "https" , "192.168.5.99" , 25081 ) ;

Operation list

The list shows the functions that can be operated at the client side.

Function nameMethod
Refer to pipeline listgetPipelineList()
Run pipelineexecutePipeline()
Start pipelineresumePipeline()
Stop pipelinesuspendPipeline()
Import pipelineimportPipeline()
Export pipelineexportPipeline()
Clear pipeline action cacheclearPipelineCache()
Refer to request listgetRequestList()
Refer to requst detailsgetRequestDetail()
Retry requestretryRequest()
Cancel requestcancelRequest()
Refer to System DBselectSystemDB()
Refer to Status DBselectStatusDB()
Refer to Action DBselectActionDB()
Clear Action DB TabledeleteActionTable()
Drop Action DB TabledropActionTable()

Proxy

Set proxy in setProxy().
The sample is as below.

package sample.client;

import java.util.List;

import java.net.Proxy ;
import java.net.SocketAddress ;
import java.net.InetSocketAddress ;

import com.infoteria.asteria.warp.mc.client.CoordinatorClient;
import com.infoteria.asteria.warp.mc.client.PipelineInfo;
import com.infoteria.asteria.net.http.speaker.client.ClientException;

public class Sample01 {
	public static void main( String[] args ) {
		try {
			String pass = "" ;
			CoordinatorClient client = new CoordinatorClient() ;

			int port = proxy port number ;
			SocketAddress addr = new InetSocketAddress( "your Proxy Server" , port ) ;
			Proxy proxy = new Proxy( Proxy.Type.HTTP , addr ) ;
			client.setProxy( proxy ) ;

			client.login( pass ) ;
			List lst = client.getPipelineList(null);
			for ( PipelineInfo pi : lst ) {
				System.out.println( pi ) ;
			}
		} catch ( Exception e ) {
			e.printStackTrace() ;
		}
	}
}

API

Here are pipeline API's link and client JavaDoc's link.

pipeline API

Click this link to go to Pipeline API .

Client JavaDoc

Click this link to go to JavaDoc.

HTTPS Communication

It's necessary to create a key store and set to HTTPS in the server side for the HTTPS communication.

Set server

Steps

  1. Create ant's project file
  2. Create a key store
  3. Edit the configuration files of the server.

Create a key store

Create cert.xml as below under [install_dir]/pipeline/

Create a key store by using ant task.

※For more information about keytool, please refer to the website about java products.

// Create by library :keystore.type will become PKCS12.
$ ant -f cert.xml -Dcert.password=yourpassword dist-keystore

// Create by keytool
$ ant -f cert.xml -Dcert.password=yourpassword dist-keystore-keytool

// Create by GenKey 
$ ant -f cert.xml -Dcert.password=yourpassword dist-keystore-genkey

// Files can be used for [install dir]/pipeline/data/keystore.
// Please run the below command for confirming content.
// If it's created by dist-keystore, please cofirm that java.home/lib/security/java.security's keystore.type=pkcs12.
// Display data
$ keytool -list -keystore data/keystore/self.keystore

Edit configuration files

The below messages can be output after running ant, so please edit [install_dir]/pipeline/conf/pipeline.ifx as below

  • Set PIPELINE-Coordinator-SSL's enable="on".
  • Add messages.

If you didn't create it in the dist-keystore, please match the keystore.type with the keystore.type's value in the java.home/lib/security/java.security.
It's better to create a backup for the configuration files when you are editing them.

> Messages about execution result
printconfig:
     [echo]
     [echo] <param name="password.encrypted">true</param>
     [echo] <param name="keystore">true</param>
     [echo] <param name="keystore.type">JKS</param>
     [echo] <param name="keystore.file">data/keystore/self.keystore</param>
     [echo] <param name="keystore.password">GZ7bG/X+EDoxXwL4aG0Nnw==</param>
     [echo] <param name="privatekey.password">GZ7bG/X+EDoxXwL4aG0Nnw==</param>
     [echo]

// Address for editing pipeline.ifx
<process id="PIPELINE-Coordinator-SSL" timeout="300" maxdeadcount="1" enable="on" statistics="true"
	manager="com.infoteria.asteria.warp.task.asframework.PipelineManagerService">
	<accepter pool="1" max="1" class="com.infoteria.asteria.warp.engine.framework.DefaultSSLAccepter">
		<param name="port">25081:TLSv3</param>
		<param name="timeout">180</param>
                         :
		<!-- Add here -->

		<param name="password.encrypted">true</param>
		<param name="keystore">true</param>
		<param name="keystore.type">JKS</param>
		<param name="keystore.file">data/keystore/self.keystore</param>
		<param name="keystore.password">GZ7bG/X+EDoxXwL4aG0Nnw==</param>
		<param name="privatekey.password">GZ7bG/X+EDoxXwL4aG0Nnw==</param>

	</accepter>
	<worker pool="1" max="32" class="com.infoteria.asteria.warp.mc.ashttpd.CoordinatorHttpdWorker">

Confirm

If the login page can be displayed after connecting to https://hostname:25081/, it means that you have completed setting.

Set client

In default, the signature error can be ignored.
Please set javax.net.ssl.HostnameVerifier or javax.net.ssl.SSLSocketFactory for setting Handshake correctly.

  • setHostnameVerifier()
  • setSSLSocketFactory()

Please refer to java's API for details.

Execution sample

The execution sample is as below.

■ If you are using CoordinatorClient's default HostnameVerifier and SSLSocketFactory.

package sample.client;

import java.util.List;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession ;
import javax.net.ssl.SSLContext ;
import javax.net.ssl.SSLSocketFactory ;
import javax.net.ssl.KeyManager ;
import javax.net.ssl.TrustManager ;

import com.infoteria.asteria.warp.mc.client.CoordinatorClient;
import com.infoteria.asteria.warp.mc.client.PipelineInfo;
import com.infoteria.asteria.net.http.speaker.client.ClientException;

public class Sample02 {
        public static void main( String[] args ) {
                try {
                        String pass = "" ;
                        CoordinatorClient client = new CoordinatorClient( "https" , "localhost" , 25081 ) ;

                        // Set HostnameVerifier
                        // HostnameVerifier verifier = do some thing 
                        // client.setHostnameVerifer( verifier ) ;

                        // Set SSLSocketFactory
                        // KeyManager[] km = do some thing ;
                        // TrustManager[] tm = do some thing ;
                        // SSLContext sslcontext= SSLContext.getInstance("SSL");
                        // sslcontext.init(km, tm, new SecureRandom());
                        // client.setSSLSocketFactory( sslcontext.getSocketFactory() ) ;

                        client.login( pass ) ;

                        List<PipelineInfo> lst = client.getPipelineList(null);
                        for ( PipelineInfo pi : lst ) {
                                System.out.println( pi ) ;
                        }
                } catch ( Exception e ) {
                        e.printStackTrace() ;
                }
        }
}

■ If set the constructor's own HostnameVerifier and SSLSocketFactory

package sample.client;

import java.util.List;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession ;
import javax.net.ssl.SSLContext ;
import javax.net.ssl.SSLSocketFactory ;
import javax.net.ssl.KeyManager ;
import javax.net.ssl.TrustManager ;

import com.infoteria.asteria.warp.mc.client.CoordinatorClient;
import com.infoteria.asteria.warp.mc.client.PipelineInfo;
import com.infoteria.asteria.net.http.speaker.client.ClientException;
import com.infoteria.asteria.net.http.speaker.client.HttpsInitializable ;

public class Sample03 {
        public static void main( String[] args ) {
                try {
                        String pass = "" ;
                        CoordinatorClient client = new CoordinatorClient( new MyHttpsInitialize()  , "hostname.net" , 25081 ) ;
                        client.login( pass ) ;
                        List<PipelineInfo> lst = client.getPipelineList(null);
                        for ( PipelineInfo pi : lst ) {
                                System.out.println( pi ) ;
                        }
                } catch ( Exception e ) {
                        e.printStackTrace() ;
                }
        }

        // Class for creating HostnameVerifier , SSLSocketFactory
        class MyHttpsInitialize implements HttpsInitializable {

                public boolean useDefaultHostnameVerifier() {
                        return false ;
                }

                public boolean useDefaultSSLSocketFactory() {
	                    return false ;
	            }

                public HostnameVerifier createHostnameVerifier() {
                        // Create HostnameVerifier
                		return new HostnameVerifier() {
                			public boolean verify( String name , SSLSession session ) {
                					return true ;
                			}
                		} ;
                }

                public SSLSocketFactory createSocketFactory() throws java.security.NoSuchAlgorithmException , java.security.KeyManagementException {
                        // Create SSLSocketFactory
                        KeyManager[] km = null;
                        TrustManager[] tm = { new X509TrustManager() {
                                public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { }
                                public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { }
                                public X509Certificate[] getAcceptedIssuers() { return null;}
                                }
                        };
                        SSLContext sslcontext= SSLContext.getInstance("SSL");
                        sslcontext.init(km, tm, new SecureRandom());
                        return sslcontext.getSocketFactory() ;
                }
        }
}
 

▲ To the top of the page