nosql:admin_console_oracle_nosql_db_11gr2
Dies ist eine alte Version des Dokuments!
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
.. public static CommandServiceAPI csi = null; public static String adminNode = "localost"; public static int adminPort = 5000; .. /** * init the Command API */ public static void init(String nodeName, int RMIPort) { log(" =============Get PerfMap Demo =========================="); try { if (csi == null) { csi = RegistryUtils.getAdmin(nodeName, RMIPort); } } catch (Exception ex) { log(ex.toString()); } }
Beispiel für den Aufruf der Performance Statistik ohne den lästigen Header der Amin Konsole:
/** * show the performance Satistik of the KStore */ public static void showPerfStat() { log(" =============Get PerfMap Demo =========================="); try { if (csi == null) { init(adminNode, adminPort); } Map<ResourceId, PerfEvent> perfmap = csi.getPerfMap(); for (PerfEvent pe : perfmap.values()) { System.out.println(pe.getColumnFormatted()); } } catch (Exception ex) { log(ex.toString()); } log(" =============Get PerfMap Demo =========================="); }
Beispiel für die Anzeige der Topology:
/** * show the Topology Overview of the KStore */ public static void showTopology(){ log(" =============show Part Map =========================="); try { if (csi == null) { init(adminNode, adminPort); } 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("Read from "+ sn.getStorageNodeId() +" read :: "+sn.toString()); } } catch (Exception ex) { log(ex.toString()); } log(" =============show Part Map =========================="); }
Beispiel für eine Anzeige des Status der einzelnen Nodes in einer CSV Sicht
public static CommandServiceAPI csi = null; public static String adminNode = "localost"; public static int adminPort = 5000; /** * init the Command API */ public static void init(String nodeName, int RMIPort) { try { if (csi == null) { csi = oracle.kv.impl.util.registry.RegistryUtils.getAdmin(nodeName, RMIPort); } } catch (Exception ex) { System.out.println(ex.toString()); } } public static void showTopology() { try { if (csi == null) { init(adminNode, adminPort); } // 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 = "MASTER"; for (StorageNode sn : topo.getSortedStorageNodes()) { sna = regUtils.getStorageNodeAgent(sn.getStorageNodeId()); snStatus = sna.ping(); status = snStatus.getServiceStatus(); System.out.printf("nosqlTopo=%s|%s|%s|null\n",sn.getStorageNodeId(),sn.toString(),status); 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 = "MASTER"; } else { repRole = "REPLICA"; } System.out.printf("nosqlTopo=%s|%s|%s|%s\n",rn2.toString(),r.toString(),status,repRole); } } } } } catch (Exception ex) { System.out.println(ex.toString()); }
nosql/admin_console_oracle_nosql_db_11gr2.1372953790.txt.gz · Zuletzt geändert: 2013/07/04 18:03 von gpipperr