Help Center > > Developer Guide> Java> CTS Java SDK Demo

CTS Java SDK Demo

Updated at: Oct 09, 2019 GMT+08:00

Tracker

A tracker will be created after CTS is enabled. All traces recorded by CTS are associated with the tracker.

Creating a Tracker

You can create a tracker using OpenStack4j based on the following code. Currently, only one tracker system can be created.

1
2
3
public void CreateTracker() { 
Tracker create = osclient.cloudTraceV1().trackers().create(bucket_name,FilePrefixName); 
}

Deleting a Tracker

You can delete a tracker using OpenStack4j based on the following code:

1
2
3
4
5
6
public void DeleteTraker() {
ActionResponse delete = osclient.cloudTraceV1().trackers().delete(tracker_name);
Assert.assertTrue(delete.isSuccess());
List<Tracker> trackers = osclient.cloudTraceV1().trackers().list();
Assert.assertTrue(trackers.size() == 0);
}

Updating a Tracker

You can update a tracker using OpenStack4j based on the following code. The information that can be updated includes the bucket name, folder name, status, and the tracker name. The tracker name is optional and can be only system.

1
2
3
4
5
public void UpdateTraker() { 
TrackerUpdate update = TrackerUpdate.builder().trackerName(tracker_name) 
.bucketName(bucket_name).filePrefixName("SDK-unittest").status(TrackerStatus.Enabled").build(); 
Tracker updated = osclient.cloudTraceV1().trackers().update(update); 
}

Querying a Tracker

You can query a tracker using OpenStack4j based on the following code by specifying tracker_name:

1
2
3
public void GetTraker() {
Tracker get = osclient.cloudTraceV1().trackers().get(tracker_name);
}

Trace

This interface is used to query records of operations on resources during the last seven days.

Querying the Trace List

You can query a trace list using OpenStack4j based on the following code. You can filter out required traces by specifying multiple parameters.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
/*v2interface*/
publicvoidListTrace(){
	TraceListOptionsoptions=TraceListOptions.create().limit(5).user("renxiaomei").serviceType("CTS");
	List<Trace>list=osclient.cloudTraceV2().traces().list("system", options);
	if(list.size()>0){
		Tracetrace=list.get(list.size()-1);
		options.marker(trace.getId());
		List<Trace>list2=osclient.cloudTraceV2().traces().list("system", options);
	}
}

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel