1515 */
1616package com .marklogic .hub ;
1717
18- import java .nio .file .Paths ;
19- import java .util .ArrayList ;
20- import java .util .HashMap ;
21- import java .util .List ;
22- import java .util .Map ;
23-
24- import org .slf4j .Logger ;
25- import org .slf4j .LoggerFactory ;
26- import org .springframework .web .client .ResourceAccessException ;
27-
2818import com .fasterxml .jackson .databind .JsonNode ;
2919import com .marklogic .appdeployer .AppConfig ;
3020import com .marklogic .appdeployer .ConfigDir ;
4636import com .marklogic .appdeployer .command .groups .DeployGroupsCommand ;
4737import com .marklogic .appdeployer .command .mimetypes .DeployMimetypesCommand ;
4838import com .marklogic .appdeployer .command .schemas .LoadSchemasCommand ;
49- import com .marklogic .appdeployer .command .security .DeployAmpsCommand ;
50- import com .marklogic .appdeployer .command .security .DeployCertificateAuthoritiesCommand ;
51- import com .marklogic .appdeployer .command .security .DeployCertificateTemplatesCommand ;
52- import com .marklogic .appdeployer .command .security .DeployExternalSecurityCommand ;
53- import com .marklogic .appdeployer .command .security .DeployPrivilegesCommand ;
54- import com .marklogic .appdeployer .command .security .DeployProtectedCollectionsCommand ;
55- import com .marklogic .appdeployer .command .security .DeployRolesCommand ;
56- import com .marklogic .appdeployer .command .security .DeployUsersCommand ;
39+ import com .marklogic .appdeployer .command .security .*;
5740import com .marklogic .appdeployer .command .tasks .DeployScheduledTasksCommand ;
5841import com .marklogic .appdeployer .command .triggers .DeployTriggersCommand ;
5942import com .marklogic .appdeployer .command .viewschemas .DeployViewSchemasCommand ;
6851import com .marklogic .client .util .RequestParameters ;
6952import com .marklogic .hub .commands .LoadHubModulesCommand ;
7053import com .marklogic .hub .commands .LoadUserModulesCommand ;
54+ import com .marklogic .hub .util .PerformanceLogger ;
7155import com .marklogic .mgmt .ManageClient ;
7256import com .marklogic .mgmt .ManageConfig ;
7357import com .marklogic .mgmt .admin .AdminConfig ;
7660import com .marklogic .mgmt .databases .DatabaseManager ;
7761import com .marklogic .rest .util .Fragment ;
7862import com .marklogic .rest .util .ResourcesFragment ;
63+ import org .slf4j .Logger ;
64+ import org .slf4j .LoggerFactory ;
65+ import org .springframework .web .client .ResourceAccessException ;
66+
67+ import java .nio .file .Paths ;
68+ import java .util .ArrayList ;
69+ import java .util .HashMap ;
70+ import java .util .List ;
71+ import java .util .Map ;
7972
8073public class DataHub {
8174
@@ -109,6 +102,8 @@ private void init(HubConfig hubConfig) {
109102 * @return true if installed, false otherwise
110103 */
111104 public boolean isInstalled () {
105+ long startTime = PerformanceLogger .monitorTimeInsideMethod ();
106+
112107 ServerManager sm = new ServerManager (client );
113108 DatabaseManager dm = new DatabaseManager (client );
114109
@@ -156,6 +151,8 @@ public boolean isInstalled() {
156151 tracingDbExists && tracingIndexesOn );
157152 boolean forestsOk = (stagingForestsExist && finalForestsExist && tracingForestsExist );
158153
154+ PerformanceLogger .logTimeInsideMethod (startTime , "DataHub.isInstalled" );
155+
159156 return (appserversOk && dbsOk && forestsOk );
160157 }
161158
@@ -164,6 +161,7 @@ public boolean isInstalled() {
164161 * @throws ServerValidationException if the server is not compatible
165162 */
166163 public void validateServer () throws ServerValidationException {
164+ long startTime = PerformanceLogger .monitorTimeInsideMethod ();
167165 try {
168166 AdminManager am = getAdminManager ();
169167 String versionString = am .getServerVersion ();
@@ -176,6 +174,7 @@ public void validateServer() throws ServerValidationException {
176174 catch (ResourceAccessException e ) {
177175 throw new ServerValidationException (e .toString ());
178176 }
177+ PerformanceLogger .logTimeInsideMethod (startTime , "DataHub.validateServer" );
179178 }
180179
181180 private AppConfig getAppConfig () {
@@ -230,14 +229,13 @@ public void updateAppConfig(AppConfig config) {
230229 }
231230
232231 public void initProject () {
233- long startTime = System . nanoTime ();
232+ long startTime = PerformanceLogger . monitorTimeInsideMethod ();
234233 LOGGER .info ("Initializing the Hub Project" );
235234
236235 HubProject hp = new HubProject (hubConfig );
237236 hp .init ();
238- long endTime = System .nanoTime ();
239- long duration = (endTime - startTime );
240- LOGGER .info ("Initialize took: " + (duration / 1000000000 ) + " seconds" );
237+
238+ PerformanceLogger .logTimeInsideMethod (startTime , "DataHub.initProject" );
241239 }
242240
243241 private DatabaseClient getDatabaseClient (int port ) {
@@ -255,8 +253,7 @@ private DatabaseClient getDatabaseClient(int port) {
255253 * Installs User Provided modules into the Data Hub
256254 */
257255 public void installUserModules () {
258- long startTime = System .nanoTime ();
259-
256+ long startTime = PerformanceLogger .monitorTimeInsideMethod ();
260257 LOGGER .debug ("Installing user modules into MarkLogic" );
261258
262259 List <Command > commands = new ArrayList <Command >();
@@ -266,17 +263,20 @@ public void installUserModules() {
266263 SimpleAppDeployer deployer = new SimpleAppDeployer (client , getAdminManager ());
267264 deployer .setCommands (commands );
268265 deployer .deploy (config );
269- long endTime = System .nanoTime ();
270- long duration = (endTime - startTime );
271- LOGGER .info ("Installing User Modules took: " + (duration / 1000000000 ) + " seconds" );
272-
266+ PerformanceLogger .logTimeInsideMethod (startTime , "DataHub.installUserModules" );
273267 }
274268
275269 public JsonNode validateUserModules () {
270+ long startTime = PerformanceLogger .monitorTimeInsideMethod ();
276271 LOGGER .debug ("validating user modules" );
272+
277273 DatabaseClient client = getDatabaseClient (hubConfig .stagingPort );
278274 EntitiesValidator ev = new EntitiesValidator (client );
279- return ev .validate ();
275+ JsonNode jsonNode = ev .validate ();
276+
277+ PerformanceLogger .logTimeInsideMethod (startTime , "DataHub.validateUserModules" );
278+
279+ return jsonNode ;
280280 }
281281
282282 private List <Command > getCommands (AppConfig config ) {
@@ -377,10 +377,9 @@ private AdminManager getAdminManager() {
377377 * Installs the data hub configuration and server-side modules into MarkLogic
378378 */
379379 public void install () {
380-
381380 initProject ();
382381
383- long startTime = System . nanoTime ();
382+ long startTime = PerformanceLogger . monitorTimeInsideMethod ();
384383 LOGGER .info ("Installing the Data Hub into MarkLogic" );
385384
386385 // clean up any lingering cache for deployed modules
@@ -392,17 +391,16 @@ public void install() {
392391 deployer .setCommands (getCommands (config ));
393392 deployer .deploy (config );
394393
395- long endTime = System .nanoTime ();
396- long duration = (endTime - startTime );
397- LOGGER .info ("Install took: " + (duration / 1000000000 ) + " seconds" );
394+ PerformanceLogger .logTimeInsideMethod (startTime , "DataHub.install" );
398395 }
399396
400397 /**
401398 * Uninstalls the data hub configuration and server-side modules from MarkLogic
402399 */
403400 public void uninstall () {
404- long startTime = System . nanoTime ();
401+ long startTime = PerformanceLogger . monitorTimeInsideMethod ();
405402 LOGGER .debug ("Uninstalling the Data Hub from MarkLogic" );
403+
406404 AppConfig config = getAppConfig ();
407405 SimpleAppDeployer deployer = new SimpleAppDeployer (client , getAdminManager ());
408406 deployer .setCommands (getCommands (config ));
@@ -411,9 +409,8 @@ public void uninstall() {
411409 // clean up any lingering cache for deployed modules
412410 PropertiesModuleManager moduleManager = new PropertiesModuleManager ();
413411 moduleManager .deletePropertiesFile ();
414- long endTime = System .nanoTime ();
415- long duration = (endTime - startTime );
416- LOGGER .info ("Uninstall took: " + (duration / 1000000000 ) + " seconds" );
412+
413+ PerformanceLogger .logTimeInsideMethod (startTime , "DataHub.uninstall" );
417414 }
418415
419416 class EntitiesValidator extends ResourceManager {
0 commit comments