nosql:admin_console_oracle_nosql_db_11gr2
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende Überarbeitung | |||
nosql:admin_console_oracle_nosql_db_11gr2 [2013/07/26 16:17] – gpipperr | nosql:admin_console_oracle_nosql_db_11gr2 [2013/07/26 16:18] (aktuell) – [Version abfragen] gpipperr | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | ===== Die Befehle der Admin Konsole der Oracle NoSQL DB im eigenen Programm integrieren ===== | ||
+ | Über die Klasse CommandServiceAPI kann auch im eigenen Programmcode auf die Befehle der Admin Konsole der NoSQL Datenbank zugegriffen werden. | ||
+ | |||
+ | === Initialisieren === | ||
+ | |||
+ | <code java> | ||
+ | |||
+ | .. | ||
+ | public static CommandServiceAPI csi = null; | ||
+ | public static String adminNode = " | ||
+ | public static int adminPort = 5000; | ||
+ | .. | ||
+ | /** | ||
+ | | ||
+ | */ | ||
+ | public static void init(String nodeName, int RMIPort) { | ||
+ | log(" | ||
+ | try { | ||
+ | if (csi == null) { | ||
+ | csi = RegistryUtils.getAdmin(nodeName, | ||
+ | } | ||
+ | |||
+ | } | ||
+ | catch (Exception ex) { | ||
+ | log(ex.toString()); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Beispiel für den Aufruf der Performance Statistik ohne den lästigen Header der Amin Konsole=== | ||
+ | |||
+ | <code java> | ||
+ | |||
+ | /** | ||
+ | * show the performance Satistik of the KStore | ||
+ | */ | ||
+ | |||
+ | public static void showPerfStat() { | ||
+ | |||
+ | log(" | ||
+ | try { | ||
+ | if (csi == null) { | ||
+ | init(adminNode, | ||
+ | } | ||
+ | |||
+ | Map< | ||
+ | |||
+ | for (PerfEvent pe : perfmap.values()) { | ||
+ | System.out.println(pe.getColumnFormatted()); | ||
+ | } | ||
+ | } | ||
+ | catch (Exception ex) { | ||
+ | log(ex.toString()); | ||
+ | } | ||
+ | |||
+ | log(" | ||
+ | } | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ===Beispiel für die Anzeige der Topology=== | ||
+ | |||
+ | <code java> | ||
+ | /** | ||
+ | * show the Topology Overview of the KStore | ||
+ | */ | ||
+ | | ||
+ | public static void showTopology(){ | ||
+ | | ||
+ | log(" | ||
+ | | ||
+ | try { | ||
+ | | ||
+ | if (csi == null) { | ||
+ | init(adminNode, | ||
+ | } | ||
+ | | ||
+ | Topology topo = csi.getTopology(); | ||
+ | PartitionMap part = topo.getPartitionMap(); | ||
+ | |||
+ | for (Topology.Component com : part.getAll()) { | ||
+ | System.out.println(com.toString()); | ||
+ | } | ||
+ | for ( StorageNode sn : topo.getSortedStorageNodes() ){ | ||
+ | System.out.println(" | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | catch (Exception ex) { | ||
+ | log(ex.toString()); | ||
+ | } | ||
+ | |||
+ | log(" | ||
+ | | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | === Beispiel für eine Anzeige des Status der einzelnen Nodes in einer CSV Sicht === | ||
+ | |||
+ | <code java> | ||
+ | |||
+ | public static void showTopologyCSV() { | ||
+ | |||
+ | try { | ||
+ | |||
+ | if (csi == null) { | ||
+ | init(adminNode, | ||
+ | } | ||
+ | |||
+ | // get the topo | ||
+ | |||
+ | Topology topo = csi.getTopology(); | ||
+ | |||
+ | //register util | ||
+ | RegistryUtils regUtils = new RegistryUtils(topo); | ||
+ | |||
+ | // grep the status | ||
+ | ServiceStatus status = ServiceStatus.UNREACHABLE; | ||
+ | // For all Storage Nodes | ||
+ | StorageNodeStatus snStatus = null; | ||
+ | StorageNodeAgentAPI sna = null; | ||
+ | |||
+ | RepNodeStatus rnStatus = null; | ||
+ | RepNodeAdminAPI rna = null; | ||
+ | String repRole = " | ||
+ | |||
+ | for (StorageNode sn : topo.getSortedStorageNodes()) { | ||
+ | sna = regUtils.getStorageNodeAgent(sn.getStorageNodeId()); | ||
+ | snStatus = sna.ping(); | ||
+ | status = snStatus.getServiceStatus(); | ||
+ | System.out.printf(" | ||
+ | |||
+ | RepGroupMap snrepgrp = topo.getRepGroupMap(); | ||
+ | for (RepGroup r : snrepgrp.getAll()) { | ||
+ | for (RepNode rn2 : r.getRepNodes()) { | ||
+ | rna = regUtils.getRepNodeAdmin(rn2.getResourceId()); | ||
+ | rnStatus = rna.ping(); | ||
+ | status = rnStatus.getServiceStatus(); | ||
+ | if (sn.getStorageNodeId().equals(rn2.getStorageNodeId())) { | ||
+ | |||
+ | if (rnStatus.getReplicationState().isMaster()) { | ||
+ | repRole = " | ||
+ | } else { | ||
+ | repRole = " | ||
+ | } | ||
+ | |||
+ | | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | } catch (Exception ex) { | ||
+ | System.out.println(ex.toString()); | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | ==== Version abfragen ==== | ||
+ | |||
+ | Erste Version, | ||
+ | |||
+ | <code java> | ||
+ | public static void showVersion() { | ||
+ | |||
+ | String version | ||
+ | String datacenter | ||
+ | String storeName | ||
+ | String numPartions = " | ||
+ | |||
+ | try { | ||
+ | |||
+ | if (csi == null) { | ||
+ | init(adminNode, | ||
+ | } | ||
+ | |||
+ | // get the topo | ||
+ | Topology topo = csi.getTopology(); | ||
+ | | ||
+ | storeName | ||
+ | numPartions = "" | ||
+ | |||
+ | //register util | ||
+ | RegistryUtils regUtils = new RegistryUtils(topo); | ||
+ | |||
+ | RepNodeAdminAPI rna = null; | ||
+ | | ||
+ | KVVersion rnVersion = null; | ||
+ | |||
+ | RepGroupMap snrepgrp = topo.getRepGroupMap(); | ||
+ | |||
+ | for (RepGroup r : snrepgrp.getAll()) { | ||
+ | for (RepNode rn2 : r.getRepNodes()) { | ||
+ | rna = regUtils.getRepNodeAdmin(rn2.getResourceId()); | ||
+ | rnVersion = rna.getInfo().getSoftwareVersion(); | ||
+ | version = rnVersion.getNumericVersionString(); | ||
+ | datacenter = topo.getDatacenter(rn2.getStorageNodeId()).getName(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | } catch (Exception ex) { | ||
+ | System.out.println(ex.toString()); | ||
+ | } | ||
+ | |||
+ | System.out.printf(" | ||
+ | |||
+ | } | ||
+ | </ |
nosql/admin_console_oracle_nosql_db_11gr2.txt · Zuletzt geändert: 2013/07/26 16:18 von gpipperr