Commit 9a60e71b authored by Yohann CINTRE's avatar Yohann CINTRE
Browse files

Adding Javadoc comments

parent ebdc0e21
/**
* (c)2010 Scalagent Distributed Technologies
* @author Yohann CINTRE
*/
package com.scalagent.appli.client;
......@@ -9,12 +8,12 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.visualization.client.VisualizationUtils;
import com.google.gwt.visualization.client.visualizations.AnnotatedTimeLine;
import com.scalagent.appli.client.event.LoginValidEvent;
import com.scalagent.appli.client.event.UpdateCompleteEvent;
import com.scalagent.appli.client.event.common.UpdateCompleteEvent;
import com.scalagent.appli.client.event.queue.DeletedQueueEvent;
import com.scalagent.appli.client.event.queue.NewQueueEvent;
import com.scalagent.appli.client.event.queue.QueueDetailClickEvent;
import com.scalagent.appli.client.event.queue.UpdatedQueueEvent;
import com.scalagent.appli.client.event.session.LoginValidEvent;
import com.scalagent.appli.client.event.subscription.DeletedSubscriptionEvent;
import com.scalagent.appli.client.event.subscription.NewSubscriptionEvent;
import com.scalagent.appli.client.event.subscription.SubscriptionDetailClickEvent;
......@@ -37,7 +36,9 @@ import com.scalagent.appli.client.widget.MainWidget;
import com.scalagent.engine.client.BaseEntryPoint;
import com.smartgwt.client.widgets.Canvas;
/**
* @author Yohann CINTRE
*/
public class Application implements BaseEntryPoint {
public static final ApplicationMessages messages = (ApplicationMessages) GWT
......@@ -46,8 +47,6 @@ public class Application implements BaseEntryPoint {
private RPCServiceAsync serviceAsync;
private RPCServiceCacheClient serviceCache;
private HandlerManager eventBus;
// private final int UPDATEDELAY = 3000;
// TODO : updatedelay en dur quelque part
/**
* This is the entry point method.
......@@ -57,9 +56,6 @@ public class Application implements BaseEntryPoint {
Runnable onLoadCallback = new Runnable() {
public void run() {
System.out.println("############################################################");
System.out.println("### appli.client.Application loaded : démarrage application");
serviceAsync = GWT.create(RPCService.class);
eventBus = new HandlerManager(null);
......@@ -107,13 +103,8 @@ public class Application implements BaseEntryPoint {
Canvas mainCanvas = (Canvas)mWidget.asWidget();
mainCanvas.draw();
}
};
// VisualizationUtils.loadVisualizationApi(onLoadCallback, LineChart.PACKAGE);
VisualizationUtils.loadVisualizationApi(onLoadCallback, AnnotatedTimeLine.PACKAGE);
}
}
/**
* (c)2010 Scalagent Distributed Technologies
* @author Yohann CINTRE
*/
package com.scalagent.appli.client;
/**
* @author Yohann CINTRE
*/
public interface ApplicationMessages extends com.google.gwt.i18n.client.Messages {
/** TOPIC WIDGET **/
......
/**
* (c)2010 Scalagent Distributed Technologies
* @author Yohann CINTRE
*/
package com.scalagent.appli.client;
......@@ -13,6 +12,8 @@ import com.scalagent.engine.client.command.Response;
/**
* The client side stub for the RPC service.
*
* @author Yohann CINTRE
*/
@RemoteServiceRelativePath("RPCService")
public interface RPCService extends BaseRPCService {
......
/**
* (c)2010 Scalagent Distributed Technologies
* @author Yohann CINTRE
*/
package com.scalagent.appli.client;
......@@ -10,7 +9,9 @@ import com.scalagent.engine.client.BaseRPCServiceAsync;
import com.scalagent.engine.client.command.Action;
import com.scalagent.engine.client.command.Response;
/**
* @author Yohann CINTRE
*/
public interface RPCServiceAsync extends BaseRPCServiceAsync {
public <R extends Response> void execute(Action<R> action, AsyncCallback<R> callback);
......
/**
* (c)2010 Scalagent Distributed Technologies
* @author Yohann CINTRE
*/
package com.scalagent.appli.client;
......@@ -10,25 +9,29 @@ import java.util.HashMap;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.Vector;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Timer;
import com.scalagent.appli.client.command.info.LoadServerInfoAction;
import com.scalagent.appli.client.command.info.LoadServerInfoResponse;
import com.scalagent.appli.client.command.info.LoadServerInfoHandler;
import com.scalagent.appli.client.command.message.LoadMessageAction;
import com.scalagent.appli.client.command.message.LoadMessageHandler;
import com.scalagent.appli.client.command.message.LoadMessageResponse;
import com.scalagent.appli.client.command.queue.LoadQueueAction;
import com.scalagent.appli.client.command.queue.LoadQueueResponse;
import com.scalagent.appli.client.command.queue.LoadQueueResponseHandler;
import com.scalagent.appli.client.command.queue.LoadQueueHandler;
import com.scalagent.appli.client.command.subscription.LoadSubscriptionAction;
import com.scalagent.appli.client.command.subscription.LoadSubscriptionResponse;
import com.scalagent.appli.client.command.subscription.LoadSubscriptionResponseHandler;
import com.scalagent.appli.client.command.subscription.LoadSubscriptionHandler;
import com.scalagent.appli.client.command.topic.LoadTopicAction;
import com.scalagent.appli.client.command.topic.LoadTopicResponse;
import com.scalagent.appli.client.command.topic.LoadTopicResponseHandler;
import com.scalagent.appli.client.command.topic.LoadTopicHandler;
import com.scalagent.appli.client.command.user.LoadUserAction;
import com.scalagent.appli.client.command.user.LoadUserResponse;
import com.scalagent.appli.client.command.user.LoadUserResponseHandler;
import com.scalagent.appli.client.event.UpdateCompleteEvent;
import com.scalagent.appli.client.command.user.LoadUserHandler;
import com.scalagent.appli.client.event.common.UpdateCompleteEvent;
import com.scalagent.appli.client.event.message.DeletedMessageEvent;
import com.scalagent.appli.client.event.message.NewMessageEvent;
import com.scalagent.appli.client.event.message.QueueNotFoundEvent;
......@@ -60,10 +63,13 @@ import com.scalagent.engine.shared.BaseWTO;
* with its stored data and fires corresponding events on the EventBus.
*
* It handles:
* - devices
* - ECWSpecifications
* - test results
* - queues
* - topics
* - users
* - subscriptions
* - messages
*
* @author Yohann CINTRE
*/
public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
......@@ -73,9 +79,7 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
public static final int USER = 3;
public static final int SUB = 4;
public static final int GLOBAL = 5;
public static final int ENGINE = 6;
public static final int NETWORK = 7;
public static final int SERVER = 6;
/** Devices available in the cache */
......@@ -92,9 +96,8 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
private SortedMap<Date, Integer> subsHistory = new TreeMap<Date, Integer>();
private SortedMap<String, SortedMap<Date, int[]>> globalHistory = new TreeMap<String, SortedMap<Date, int[]>>();
private SortedMap<Date, float[]> engineHistory = new TreeMap<Date, float[]>();
private SortedMap<Date, float[]> networkHistory = new TreeMap<Date, float[]>();
private SortedMap<Date, float[]> serverHistory = new TreeMap<Date, float[]>();
private RPCServiceAsync RPCService;
private HandlerManager eventBus;
......@@ -103,17 +106,15 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
private boolean queueRequest = true;
private boolean userRequest = true;
private boolean subRequest = true;
private boolean servRequest = true;
public RPCServiceCacheClient(RPCServiceAsync RPCService, HandlerManager eventBus, int updatePeriod) {
System.out.println("### appli.client.RPCServiceCacheClient loaded : création du cache client");
this.RPCService = RPCService;
this.eventBus = eventBus;
// start the timer, to update periodically the cache
if (updatePeriod != -1) {
System.out.println("### appli.client.RPCServiceCacheClient.RPCServiceCacheClient timer du cache client : "+updatePeriod);
Timer timer = new RPCServiceCacheTimer(this);
timer.scheduleRepeating(updatePeriod);
}
......@@ -131,8 +132,7 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
public SortedMap<Date, Integer> getUsersHistory() { return usersHistory; }
public SortedMap<Date, Integer> getSubsHistory() { return subsHistory; }
public SortedMap<Date, int[]> getSpecificHistory(String name) { return globalHistory.get(name); }
public SortedMap<Date, float[]> getEngineHistory() { return engineHistory; }
public SortedMap<Date, float[]> getNetworkHistory() { return networkHistory; }
public SortedMap<Date, float[]> getServerHistory() { return serverHistory; }
@SuppressWarnings("deprecation")
......@@ -152,28 +152,22 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
topicsHistory.put(nowSec, new Integer((int)value[0]));
}
break;
case USER:
if(!usersHistory.containsKey(nowSec)) {
usersHistory.put(nowSec, new Integer((int)value[0]));
}
break;
case SUB:
if(!subsHistory.containsKey(nowSec)) {
subsHistory.put(nowSec, new Integer((int)value[0]));
}
break;
case ENGINE:
if(!engineHistory.containsKey(nowSec)) {
engineHistory.put(nowSec, value);
}
break;
case NETWORK:
if(!networkHistory.containsKey(nowSec)) {
networkHistory.put(nowSec, value);
case SERVER:
if(!serverHistory.containsKey(nowSec)) {
serverHistory.put(nowSec, value);
}
break;
......@@ -184,7 +178,7 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
@SuppressWarnings("deprecation")
public void addToSpecificHistory(String name, int... value) {
Date nowMilli = new Date();
Date nowSec = new Date(nowMilli.getYear(), nowMilli.getMonth(), nowMilli.getDay(), nowMilli.getHours(), nowMilli.getMinutes(), nowMilli.getSeconds());
......@@ -198,10 +192,9 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
mapDate.put(nowSec, value);
}
}
public void setPeriod(int updatePeriod) {
if (updatePeriod != -1) {
System.out.println("### appli.client.RPCServiceCacheClient.setPeriod timer du cache client : "+updatePeriod);
Timer timer = new RPCServiceCacheTimer(this);
timer.scheduleRepeating(updatePeriod);
}
......@@ -209,7 +202,7 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
/**
* Called periodically by the TestRPCServiceCacheTimer
* Called periodically by the RPCServiceCacheTimer
* in order to update data.
* Depending on the type of objects:
* - events are fired on the event bus,
......@@ -220,7 +213,7 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
if (topicRequest) {
topicRequest = false;
LoadTopicAction action = new LoadTopicAction((topics.isEmpty()), forceUpdate);
RPCService.execute(action, new LoadTopicResponseHandler(eventBus) {
RPCService.execute(action, new LoadTopicHandler(eventBus) {
@Override
public void onSuccess(LoadTopicResponse response) {
if(response != null) {
......@@ -237,7 +230,7 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
if (queueRequest) {
queueRequest = false;
LoadQueueAction action = new LoadQueueAction((queues.isEmpty()), forceUpdate);
RPCService.execute(action, new LoadQueueResponseHandler(eventBus) {
RPCService.execute(action, new LoadQueueHandler(eventBus) {
@Override
public void onSuccess(LoadQueueResponse response) {
if(response != null) {
......@@ -264,7 +257,7 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
}
});
}
public void retrieveMessageSub(SubscriptionWTO sub) {
RPCService.execute(new LoadMessageAction(sub.getName()), new LoadMessageHandler(eventBus) {
@Override
......@@ -284,7 +277,7 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
if (userRequest) {
userRequest = false;
LoadUserAction action = new LoadUserAction((users.isEmpty()), forceUpdate);
RPCService.execute(action, new LoadUserResponseHandler(eventBus) {
RPCService.execute(action, new LoadUserHandler(eventBus) {
@Override
public void onSuccess(LoadUserResponse response) {
if(response != null) {
......@@ -301,7 +294,7 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
if (subRequest) {
subRequest = false;
LoadSubscriptionAction action = new LoadSubscriptionAction((subs.isEmpty()), forceUpdate);
RPCService.execute(action, new LoadSubscriptionResponseHandler(eventBus) {
RPCService.execute(action, new LoadSubscriptionHandler(eventBus) {
@Override
public void onSuccess(LoadSubscriptionResponse response) {
if(response != null) {
......@@ -314,6 +307,22 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
}
}
public void retrieveServerInfo(boolean forceUpdate) {
if (servRequest) {
servRequest = false;
LoadServerInfoAction action = new LoadServerInfoAction(forceUpdate);
RPCService.execute(action, new LoadServerInfoHandler(eventBus) {
@Override
public void onSuccess(LoadServerInfoResponse response) {
if(response != null) {
processInfos(response.getInfos());
servRequest = true;
}
eventBus.fireEvent(new UpdateCompleteEvent("sub"));
}
});
}
}
/**
* Using dbChangeStatus attribute, update the list of cached devices.
......@@ -393,10 +402,10 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
if(newMessages!=null) {
for (int i=0;i<newMessages.size();i++) {
MessageWTO message = newMessages.get(i);
boolean processed = false;
queues.get(queueName).addMessageToList(message.getIdS());
// new queue
......@@ -488,4 +497,19 @@ public class RPCServiceCacheClient implements BaseRPCServiceCacheClient {
}
}
private void processInfos(Vector<Float> infos) {
if(infos!=null) {
Float[] arr1 = new Float[infos.size()];
infos.toArray(arr1);
float[] arr2 = new float[infos.size()];
for(int i=0; i<arr1.length; i++) {
arr2[i] = arr1[i];
}
addToHistory(SERVER, arr2);
}
}
}
/**
* (c)2010 Scalagent Distributed Technologies
* @author Yohann CINTRE
*/
package com.scalagent.appli.client;
import com.google.gwt.user.client.Timer;
/**
* @author Yohann CINTRE
*/
public class RPCServiceCacheTimer extends Timer {
private RPCServiceCacheClient cache;
public RPCServiceCacheTimer(RPCServiceCacheClient cache) {
System.out.println("### appli.client.RPCServiceCacheTimer loaded : création du timer pour le cache client");
this.cache = cache;
}
@Override
public void run() {
System.out.println("############################################################");
System.out.println("### appli.client.RPCServiceCacheTimer run : maj du cache client");
cache.retrieveQueue(false);
cache.retrieveTopic(false);
cache.retrieveUser(false);
cache.retrieveSubscription(false);
cache.retrieveServerInfo(false);
}
}
/**
* (c)2010 Scalagent Distributed Technologies
* @author Yohann CINTRE
*/
package com.scalagent.appli.client.command;
import com.scalagent.appli.server.command.RefreshAllActionImpl;
import com.scalagent.engine.client.command.Action;
import com.scalagent.engine.client.command.CalledMethod;
/**
* This action asks for devices list from the server.
*/
@CalledMethod(value=RefreshAllActionImpl.class)
public class RefreshAllAction implements Action<RefreshAllResponse> {
public RefreshAllAction() {}
}
/**
* (c)2010 Scalagent Distributed Technologies
* @author Yohann CINTRE
*/
package com.scalagent.appli.client.command;
import com.google.gwt.event.shared.HandlerManager;
import com.scalagent.engine.client.command.Handler;
public abstract class RefreshAllHandler extends Handler<RefreshAllResponse> {
public RefreshAllHandler(HandlerManager eventBus) {
super(eventBus);
}
}
/**
* (c)2010 Scalagent Distributed Technologies
* @author Yohann CINTRE
*/
package com.scalagent.appli.client.command;
import com.scalagent.engine.client.command.Response;
/**
* Response to the action GetDevicesAction.
*/
public class RefreshAllResponse implements Response {
private boolean success;
private String message;
public RefreshAllResponse() {}
public RefreshAllResponse(boolean success, String message) {
this.success = success;
this.message = message;
}
public boolean isSuccess() {
return success;
}
public String getMessage() {
return message;
}
}
/**
* (c)2010 Scalagent Distributed Technologies
*/
package com.scalagent.appli.client.command.info;
import com.scalagent.appli.server.command.info.LoadServerInfoActionImpl;
import com.scalagent.engine.client.command.Action;
import com.scalagent.engine.client.command.CalledMethod;
/**
* This action load the server info (engine and network utilization) from the server
* @author Yohann CINTRE
*/
@CalledMethod(value=LoadServerInfoActionImpl.class)
public class LoadServerInfoAction implements Action<LoadServerInfoResponse>{
private boolean forceUpdate;
public LoadServerInfoAction(){}
public LoadServerInfoAction(boolean forceUpdate){
this.forceUpdate = forceUpdate;
}
public boolean isforceUpdate() {
return forceUpdate;
}
}
/**
* (c)2010 Scalagent Distributed Technologies
* @author Yohann CINTRE
*/
package com.scalagent.appli.client.command.session;
import com.google.gwt.event.shared.HandlerManager;
import com.scalagent.engine.client.command.Handler;
public abstract class GetSessionHandler extends Handler<GetSessionResponse> {
public GetSessionHandler(HandlerManager eventBus) {
super(eventBus);
}
}
/**
* (c)2010 Scalagent Distributed Technologies
*/
package com.scalagent.appli.client.command.info;
import com.google.gwt.event.shared.HandlerManager;
import com.scalagent.engine.client.command.Handler;
/**
* @author Yohann CINTRE
*/
public abstract class LoadServerInfoHandler extends Handler<LoadServerInfoResponse>{
public LoadServerInfoHandler(HandlerManager eventBus){
super(eventBus);
}
}
/**
* (c)2010 Scalagent Distributed Technologies
*/
package com.scalagent.appli.client.command.info;
import java.util.Vector;
import com.scalagent.engine.client.command.Response;
/**
* Response to the action LoadServerAction
*
* @author Yohann CINTRE
*/
public class LoadServerInfoResponse implements Response{
private Vector<Float> infos;