diff options
author | Ryan D. Brooks | 2015-01-26 21:53:34 +0000 |
---|---|---|
committer | donald.g.dunne | 2017-03-21 02:08:33 +0000 |
commit | 407b1cb626302fc5dabfd56271da86995618d4df (patch) | |
tree | fa40af37602af8dc19e7b45660d9b5c330df7b08 /plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal | |
parent | e95211879cea7c4331653a44a6ef213c041e47f6 (diff) | |
download | org.eclipse.osee-407b1cb626302fc5dabfd56271da86995618d4df.tar.gz org.eclipse.osee-407b1cb626302fc5dabfd56271da86995618d4df.tar.xz org.eclipse.osee-407b1cb626302fc5dabfd56271da86995618d4df.zip |
feature: Create database health rest api
Change-Id: I33c42fd80d189f428cf2c81d1bdfca982d75aa4f
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal')
3 files changed, 97 insertions, 48 deletions
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DbHeathApplication.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DbHeathApplication.java new file mode 100644 index 00000000000..256e37b5f64 --- /dev/null +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DbHeathApplication.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2015 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.orcs.db.internal; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; +import org.eclipse.osee.jdbc.JdbcService; +import org.eclipse.osee.orcs.db.internal.health.DatabaseHealthResource; + +/** + * @author Ryan D. Brooks + */ +@ApplicationPath("db") +public final class DbHeathApplication extends Application { + + private JdbcService jdbcService; + + private final Set<Object> singletons = new HashSet<Object>(); + + public void setJdbcService(JdbcService jdbcService) { + this.jdbcService = jdbcService; + } + + @Override + public Set<Object> getSingletons() { + return singletons; + } + + public void start(Map<String, Object> properties) { + singletons.add(new DatabaseHealthResource(properties, jdbcService)); + } + + public void stop() { + singletons.clear(); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/console/TxPruneCommand.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/console/TxPruneCommand.java deleted file mode 100644 index e00cc2206cb..00000000000 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/console/TxPruneCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Boeing. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.orcs.db.internal.console; - -import java.util.concurrent.Callable; -import org.eclipse.osee.console.admin.Console; -import org.eclipse.osee.console.admin.ConsoleParameters; -import org.eclipse.osee.orcs.db.internal.callable.PurgeUnusedBackingDataAndTransactions; - -/** - * @author Roberto E. Escobar - */ -public class TxPruneCommand extends AbstractDatastoreConsoleCommand { - - @Override - public String getName() { - return "db_tx_prune"; - } - - @Override - public String getDescription() { - return "Purge artifact, attribute, and relation versions that are not addressed or non-existent and purge empty transactions"; - } - - @Override - public String getUsage() { - return ""; - } - - @Override - public Callable<?> createCallable(Console console, ConsoleParameters params) { - return new Callable<Void>() { - @Override - public Void call() throws Exception { - new PurgeUnusedBackingDataAndTransactions(getJdbcClient()).purge(); - return null; - } - }; - } -} diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/health/DatabaseHealthResource.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/health/DatabaseHealthResource.java new file mode 100644 index 00000000000..061fef5f8c5 --- /dev/null +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/health/DatabaseHealthResource.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2015 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.orcs.db.internal.health; + +import java.util.Map; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import org.eclipse.osee.jdbc.JdbcClient; +import org.eclipse.osee.jdbc.JdbcService; +import org.eclipse.osee.orcs.db.internal.callable.PurgeUnusedBackingDataAndTransactions; + +/** + * @author Ryan D. Brooks + */ +@Path("/health") +public final class DatabaseHealthResource { + private final Map<String, Object> properties; + private final JdbcClient jdbcClient; + + public DatabaseHealthResource(Map<String, Object> properties, JdbcService jdbcService) { + this.properties = properties; + this.jdbcClient = jdbcService.getClient(); + } + + @Path("purgeunused") + @GET + @Produces(MediaType.TEXT_HTML) + public String deleteObsoleteData() { + PurgeUnusedBackingDataAndTransactions app = new PurgeUnusedBackingDataAndTransactions(jdbcClient); + int[] counts = app.purge(); + + StringBuilder strB = new StringBuilder(); + for (int count : counts) { + strB.append(count); + strB.append("<br />"); + } + return strB.toString(); + } + +}
\ No newline at end of file |