Skip to content

Commit 3ebbd4f

Browse files
Implemented SVY-9377
In the Client Perfomance section of the admin page we should show the running time of the functions with and w/o the api calls running time
1 parent f826369 commit 3ebbd4f

File tree

7 files changed

+330
-79
lines changed

7 files changed

+330
-79
lines changed

servoy_ngclient/src/com/servoy/j2db/server/ngclient/NGClientWindow.java

+60-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This file belongs to the Servoy development and deployment environment, Copyrigh
1818
package com.servoy.j2db.server.ngclient;
1919

2020
import java.io.IOException;
21+
import java.rmi.RemoteException;
2122
import java.util.HashMap;
2223
import java.util.Map;
2324
import java.util.concurrent.CancellationException;
@@ -28,16 +29,21 @@ This file belongs to the Servoy development and deployment environment, Copyrigh
2829
import org.sablo.eventthread.EventDispatcher;
2930
import org.sablo.specification.PropertyDescription;
3031
import org.sablo.specification.WebObjectApiDefinition;
32+
import org.sablo.specification.property.IBrowserConverterContext;
3133
import org.sablo.websocket.BaseWindow;
3234
import org.sablo.websocket.CurrentWindow;
35+
import org.sablo.websocket.IToJSONWriter;
3336
import org.sablo.websocket.IWebsocketEndpoint;
3437

3538
import com.servoy.j2db.FlattenedSolution;
39+
import com.servoy.j2db.dataprocessing.IDataServer;
3640
import com.servoy.j2db.persistence.Form;
3741
import com.servoy.j2db.persistence.Solution;
3842
import com.servoy.j2db.server.ngclient.endpoint.INGClientWebsocketEndpoint;
43+
import com.servoy.j2db.server.shared.IPerfomanceRegistry;
3944
import com.servoy.j2db.util.Debug;
4045
import com.servoy.j2db.util.Pair;
46+
import com.servoy.j2db.util.UUID;
4147

4248
/**
4349
* Sablo window for NGClient
@@ -102,7 +108,8 @@ protected Object invokeApi(WebComponent receiver, WebObjectApiDefinition apiFunc
102108
Map<String, Object> call = new HashMap<>();
103109
if (callContributions != null) call.putAll(callContributions);
104110

105-
if (!isDelayedApiCall(receiver, apiFunction))
111+
boolean delayedCall = isDelayedApiCall(receiver, apiFunction);
112+
if (!delayedCall)
106113
{
107114
IWebFormController form = websocketSession.getClient().getFormManager().getForm(receiver.findParent(IWebFormUI.class).getName());
108115
touchForm(form.getForm(), form.getName(), false);
@@ -113,7 +120,30 @@ protected Object invokeApi(WebComponent receiver, WebObjectApiDefinition apiFunc
113120
call.put("propertyPath", componentContext.getPropertyPath());
114121
}
115122

116-
return super.invokeApi(receiver, apiFunction, arguments, argumentTypes, call);
123+
IPerfomanceRegistry perfRegistry = null;
124+
try
125+
{
126+
perfRegistry = getClient().getApplicationServerAccess().getFunctionPerfomanceRegistry();
127+
}
128+
catch (RemoteException e)
129+
{
130+
Debug.error(e);
131+
}
132+
133+
Pair<UUID, UUID> perfId = null;
134+
if (perfRegistry != null && !delayedCall) // so it is waiting for a response
135+
perfId = perfRegistry.getPerformanceData(getClient().getSolutionName()).startSubAction(
136+
receiver.getSpecification().getName() + "." + apiFunction.getName(), System.currentTimeMillis(),
137+
apiFunction.getBlockEventProcessing() ? IDataServer.METHOD_CALL : IDataServer.METHOD_CALL_WAITING_FOR_USER_INPUT, getClient().getClientID());
138+
try
139+
{
140+
// actual call
141+
return super.invokeApi(receiver, apiFunction, arguments, argumentTypes, call);
142+
}
143+
finally
144+
{
145+
if (perfId != null) perfRegistry.getPerformanceData(getClient().getSolutionName()).endSubAction(perfId);
146+
}
117147
}
118148

119149
@Override
@@ -342,4 +372,32 @@ protected boolean formLoaded(WebComponent component)
342372
return false;
343373
}
344374

375+
@Override
376+
public Object executeServiceCall(String serviceName, String functionName, Object[] arguments, WebObjectApiDefinition apiFunction,
377+
IToJSONWriter<IBrowserConverterContext> pendingChangesWriter, boolean blockEventProcessing) throws IOException
378+
{
379+
IPerfomanceRegistry perfRegistry = null;
380+
try
381+
{
382+
perfRegistry = getClient().getApplicationServerAccess().getFunctionPerfomanceRegistry();
383+
}
384+
catch (RemoteException e)
385+
{
386+
Debug.error(e);
387+
}
388+
389+
Pair<UUID, UUID> perfId = perfRegistry.getPerformanceData(getClient().getSolutionName()).startSubAction(serviceName + "." + functionName,
390+
System.currentTimeMillis(),
391+
(apiFunction == null || apiFunction.getBlockEventProcessing()) ? IDataServer.METHOD_CALL : IDataServer.METHOD_CALL_WAITING_FOR_USER_INPUT,
392+
getClient().getClientID());
393+
try
394+
{
395+
return super.executeServiceCall(serviceName, functionName, arguments, apiFunction, pendingChangesWriter, blockEventProcessing);
396+
}
397+
finally
398+
{
399+
if (perfId != null) perfRegistry.getPerformanceData(getClient().getSolutionName()).endSubAction(perfId);
400+
}
401+
}
402+
345403
}

servoy_ngclient/src/com/servoy/j2db/server/ngclient/NGRuntimeWindow.java

+30-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This file belongs to the Servoy development and deployment environment, Copyrigh
1818
package com.servoy.j2db.server.ngclient;
1919

2020
import java.io.IOException;
21+
import java.rmi.RemoteException;
2122
import java.util.HashMap;
2223
import java.util.Map;
2324
import java.util.concurrent.CancellationException;
@@ -30,15 +31,19 @@ This file belongs to the Servoy development and deployment environment, Copyrigh
3031
import com.servoy.j2db.IBasicFormManager.History;
3132
import com.servoy.j2db.IBasicMainContainer;
3233
import com.servoy.j2db.IFormController;
34+
import com.servoy.j2db.dataprocessing.IDataServer;
3335
import com.servoy.j2db.dataprocessing.PrototypeState;
3436
import com.servoy.j2db.dataprocessing.TagResolver;
3537
import com.servoy.j2db.persistence.Form;
3638
import com.servoy.j2db.persistence.Solution;
3739
import com.servoy.j2db.scripting.JSWindow;
3840
import com.servoy.j2db.scripting.RuntimeWindow;
3941
import com.servoy.j2db.server.ngclient.component.WebFormController;
42+
import com.servoy.j2db.server.shared.IPerfomanceRegistry;
4043
import com.servoy.j2db.util.Debug;
44+
import com.servoy.j2db.util.Pair;
4145
import com.servoy.j2db.util.Text;
46+
import com.servoy.j2db.util.UUID;
4247
import com.servoy.j2db.util.Utils;
4348

4449
/**
@@ -396,7 +401,8 @@ public void hideUI()
396401
}
397402
else if (getApplication().getRuntimeWindowManager().getMainApplicationWindow() != null)
398403
{
399-
if (getApplication().getRuntimeWindowManager().getMainApplicationWindow() != null) formController = getApplication().getRuntimeWindowManager().getMainApplicationWindow().getController();
404+
if (getApplication().getRuntimeWindowManager().getMainApplicationWindow() != null)
405+
formController = getApplication().getRuntimeWindowManager().getMainApplicationWindow().getController();
400406
}
401407
if (formController instanceof IWebFormController) getApplication().getFormManager().setCurrentControllerJS((IWebFormController)formController);
402408

@@ -446,7 +452,29 @@ protected void doOldShow(String formName, boolean closeAll, boolean legacyV3Beha
446452
{
447453
Debug.log(e);
448454
}
449-
getApplication().getWebsocketSession().getEventDispatcher().suspend(this, IEventDispatcher.EVENT_LEVEL_DEFAULT, IEventDispatcher.NO_TIMEOUT);
455+
456+
IPerfomanceRegistry perfRegistry = null;
457+
try
458+
{
459+
perfRegistry = getApplication().getApplicationServerAccess().getFunctionPerfomanceRegistry();
460+
}
461+
catch (RemoteException e)
462+
{
463+
Debug.error(e);
464+
}
465+
466+
Pair<UUID, UUID> perfId = perfRegistry.getPerformanceData(getApplication().getSolutionName()).startSubAction("$windowService.show",
467+
System.currentTimeMillis(), IDataServer.METHOD_CALL_WAITING_FOR_USER_INPUT, getApplication().getClientID());
468+
try
469+
{
470+
getApplication().getWebsocketSession().getEventDispatcher().suspend(this, IEventDispatcher.EVENT_LEVEL_DEFAULT,
471+
IEventDispatcher.NO_TIMEOUT);
472+
}
473+
finally
474+
{
475+
if (perfId != null) perfRegistry.getPerformanceData(getApplication().getSolutionName()).endSubAction(perfId);
476+
}
477+
450478
// this is now a hide of this window, set back the window name just before this show.
451479
getApplication().getRuntimeWindowManager().setCurrentWindowName(currentWindowName);
452480
}

servoy_shared/src/com/servoy/j2db/dataprocessing/IDataServer.java

+11-31
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This file belongs to the Servoy development and deployment environment, Copyrigh
3131

3232
/**
3333
* Interface for manipulation database data
34-
*
34+
*
3535
* @author jblok
3636
*/
3737
public interface IDataServer extends ILockServer, IMaintenanceServer, Remote
@@ -54,13 +54,14 @@ public interface IDataServer extends ILockServer, IMaintenanceServer, Remote
5454
public static final int USERMANAGEMENT_QUERY = 16;
5555
public static final int META_DATA_QUERY = 17;
5656
public static final int METHOD_CALL = 18;
57+
public static final int METHOD_CALL_WAITING_FOR_USER_INPUT = 19;
5758

5859

5960
public static final String BLOB_MARKER_COLUMN_ALIAS = "SV_BLOB_M"; //$NON-NLS-1$
6061

6162
/**
6263
* Main query method on databases.
63-
*
64+
*
6465
* @param client_id client ID
6566
* @param server_name the server to use
6667
* @param transaction_id id or null if none
@@ -97,30 +98,9 @@ public IDataSet performQuery(String client_id, String server_name, String driver
9798
public IDataSet performCustomQuery(String client_id, String server_name, String driverTableName, String transaction_id, ISQLSelect sqlSelect,
9899
ArrayList<TableFilter> filters, int startRow, int rowsToRetrieve) throws ServoyException, RemoteException;
99100

100-
/**
101-
*
102-
* @param client_id
103-
* @param server_name
104-
* @param transaction_id
105-
* @param array
106-
* @return
107-
* @throws ServoyException
108-
* @throws RemoteException
109-
*/
110101
public IDataSet[] performQuery(String client_id, String server_name, String transaction_id, QueryData[] array) throws ServoyException, RemoteException;
111102

112103

113-
/**
114-
* @param action from ISQLStatement static fields
115-
* @param server_name server name in lower case to work on
116-
* @param tableName table name in lowercase to work on
117-
* @param pkColumnData must be db compatible types and columns ordered a-z when having mulitple columns
118-
* @param tid transaction id, can be null if not present
119-
* @param sql the SQL to execute
120-
* @param questiondata the data for the question marks (must be db compatible types)
121-
* @return the statement
122-
* @throws RemoteException
123-
*/
124104
public ISQLStatement createSQLStatement(int action, String server_name, String tableName, Object[] pkColumnData, String tid, String sql,
125105
Object[] questiondata) throws RemoteException, RepositoryException;
126106

@@ -132,7 +112,7 @@ public boolean notifyDataChange(String client_id, String server_name, String tab
132112

133113
/**
134114
* Change or Add data in database
135-
*
115+
*
136116
* @param client_id the client ID
137117
* @param statements the changes
138118
* @return the values from the dbsequences for each statement
@@ -141,12 +121,12 @@ public boolean notifyDataChange(String client_id, String server_name, String tab
141121
*/
142122
public Object[] performUpdates(String clientId, ISQLStatement[] statements) throws ServoyException, RemoteException;
143123

144-
public Blob getBlob(String clientId, String serverName, ISQLSelect blobSelect, ArrayList<TableFilter> filters, String tid) throws RepositoryException,
145-
RemoteException;
124+
public Blob getBlob(String clientId, String serverName, ISQLSelect blobSelect, ArrayList<TableFilter> filters, String tid)
125+
throws RepositoryException, RemoteException;
146126

147127
/**
148128
* Start a transaction in backend DB.
149-
*
129+
*
150130
* @param client_id the client ID
151131
* @param server_name start transaction for specified server
152132
* @return String the id
@@ -157,7 +137,7 @@ public Blob getBlob(String clientId, String serverName, ISQLSelect blobSelect, A
157137

158138
/**
159139
* End a started transaction in backend DB.
160-
*
140+
*
161141
* @param transaction_id id to end
162142
* @param commit true for commit or false for rollback
163143
* @return boolean true if success full
@@ -173,7 +153,7 @@ public Blob getBlob(String clientId, String serverName, ISQLSelect blobSelect, A
173153

174154
/**
175155
* Insert a data set in a table. When tableName is null a temporary table will be created
176-
*
156+
*
177157
* @param client_id
178158
* @param set
179159
* @param dataSource
@@ -192,7 +172,7 @@ public ITable insertDataSet(String client_id, IDataSet set, String dataSource, S
192172

193173
/**
194174
* Insert a data from a query in a table. When tableName is null a temporary table will be created
195-
*
175+
*
196176
* @param client_id
197177
* @param queryServerName
198178
* @param queryTid
@@ -222,7 +202,7 @@ public ITable insertQueryResult(String client_id, String queryServerName, String
222202

223203
/**
224204
* Get the sql from the remote server, needed for databasemanager.getSQL() and databasemanager.getSQLParameters() in scripting.
225-
*
205+
*
226206
* @param serverName
227207
* @param sqlQuery
228208
* @param startRow

0 commit comments

Comments
 (0)