This repository has been archived by the owner on Jul 11, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BZ 1120418] Starting pseudo-code for executing a job.
- Loading branch information
Stefan Negrea
committed
Jul 31, 2014
1 parent
7a277ae
commit 9891be2
Showing
5 changed files
with
73 additions
and
12 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
...src/main/java/org/rhq/enterprise/server/storage/maintenance/job/MaintenanceJobRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* RHQ Management Platform | ||
* Copyright (C) 2005-2014 Red Hat, Inc. | ||
* All rights reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation version 2 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
*/ | ||
package org.rhq.enterprise.server.storage.maintenance.job; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.ejb.EJB; | ||
|
||
import org.rhq.core.domain.storage.MaintenanceJob; | ||
import org.rhq.core.domain.storage.MaintenanceStep; | ||
import org.rhq.enterprise.server.storage.maintenance.step.MaintenanceStepRunner; | ||
import org.rhq.enterprise.server.storage.maintenance.step.ShutdownStorageClient; | ||
import org.rhq.enterprise.server.storage.maintenance.step.StartStorageClient; | ||
import org.rhq.enterprise.server.storage.maintenance.step.UpdateStorageNodeEndpoints; | ||
import org.rhq.enterprise.server.storage.maintenance.step.UpdateStorageNodeEntity; | ||
|
||
public class MaintenanceJobRunner { | ||
|
||
@EJB | ||
StartStorageClient startStorageClient; | ||
|
||
@EJB | ||
ShutdownStorageClient shutdownStorageClient; | ||
|
||
@EJB | ||
UpdateStorageNodeEndpoints updateStorageNodeEndpoints; | ||
|
||
@EJB | ||
UpdateStorageNodeEntity updateStorageNodeEntity; | ||
|
||
|
||
public void runJob(MaintenanceJob job) { | ||
Map<String, MaintenanceStepRunner> runners = new HashMap<String, MaintenanceStepRunner>(); | ||
runners.put(startStorageClient.getClass().getSimpleName(), startStorageClient); | ||
runners.put(shutdownStorageClient.getClass().getSimpleName(), shutdownStorageClient); | ||
runners.put(updateStorageNodeEndpoints.getClass().getSimpleName(), updateStorageNodeEndpoints); | ||
runners.put(updateStorageNodeEntity.getClass().getSimpleName(), updateStorageNodeEntity); | ||
|
||
|
||
for (MaintenanceStep step : job.getMaintenanceSteps()) { | ||
try { | ||
runners.get(step.getOperationName()).execute(step); | ||
} catch (Exception e) { | ||
//do nothing for now ... exception handling to be decided a later | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters