Search in sources :

Example 1 with SocketHubAppender

use of org.apache.log4j.net.SocketHubAppender in project voltdb by VoltDB.

the class SystemInformation method populateOverviewTable.

/**
     * Accumulate per-host information and return as a table.
     * This function does the real work. Everything else is
     * boilerplate sysproc stuff.
     */
public static VoltTable populateOverviewTable() {
    VoltTable vt = constructOverviewTable();
    int hostId = VoltDB.instance().getHostMessenger().getHostId();
    // try to get the external interface first, if none was set, use local addresses
    InetAddress addr = null;
    String clientInterface = null;
    int clientPort = VoltDB.DEFAULT_PORT;
    String adminInterface = null;
    int adminPort = VoltDB.DEFAULT_ADMIN_PORT;
    String httpInterface = null;
    int httpPort = VoltDB.DEFAULT_HTTP_PORT;
    String internalInterface = null;
    int internalPort = Constants.DEFAULT_INTERNAL_PORT;
    String zkInterface = null;
    int zkPort = Constants.DEFAULT_ZK_PORT;
    String drInterface = null;
    int drPort = VoltDB.DEFAULT_DR_PORT;
    String publicInterface = null;
    try {
        String localMetadata = VoltDB.instance().getLocalMetadata();
        JSONObject jsObj = new JSONObject(localMetadata);
        JSONArray interfaces = jsObj.getJSONArray("interfaces");
        String iface = interfaces.getString(0);
        addr = InetAddress.getByName(iface);
        clientPort = jsObj.getInt("clientPort");
        clientInterface = jsObj.getString("clientInterface");
        adminPort = jsObj.getInt("adminPort");
        adminInterface = jsObj.getString("adminInterface");
        httpPort = jsObj.getInt("httpPort");
        httpInterface = jsObj.getString("httpInterface");
        internalPort = jsObj.getInt("internalPort");
        internalInterface = jsObj.getString("internalInterface");
        zkPort = jsObj.getInt("zkPort");
        zkInterface = jsObj.getString("zkInterface");
        drPort = jsObj.getInt("drPort");
        drInterface = jsObj.getString("drInterface");
        publicInterface = jsObj.getString("publicInterface");
    } catch (JSONException e) {
        hostLog.info("Failed to get local metadata, falling back to first resolvable IP address.");
    } catch (UnknownHostException e) {
        hostLog.info("Failed to determine hostname, falling back to first resolvable IP address.");
    }
    // host name and IP address.
    if (addr == null) {
        addr = org.voltcore.utils.CoreUtils.getLocalAddress();
    }
    vt.addRow(hostId, "IPADDRESS", addr.getHostAddress());
    vt.addRow(hostId, "HOSTNAME", CoreUtils.getHostnameOrAddress());
    vt.addRow(hostId, "CLIENTINTERFACE", clientInterface);
    vt.addRow(hostId, "CLIENTPORT", Integer.toString(clientPort));
    vt.addRow(hostId, "ADMININTERFACE", adminInterface);
    vt.addRow(hostId, "ADMINPORT", Integer.toString(adminPort));
    vt.addRow(hostId, "HTTPINTERFACE", httpInterface);
    vt.addRow(hostId, "HTTPPORT", Integer.toString(httpPort));
    vt.addRow(hostId, "INTERNALINTERFACE", internalInterface);
    vt.addRow(hostId, "INTERNALPORT", Integer.toString(internalPort));
    vt.addRow(hostId, "ZKINTERFACE", zkInterface);
    vt.addRow(hostId, "ZKPORT", Integer.toString(zkPort));
    vt.addRow(hostId, "DRINTERFACE", drInterface);
    vt.addRow(hostId, "DRPORT", Integer.toString(drPort));
    vt.addRow(hostId, "PUBLICINTERFACE", publicInterface);
    // build string
    vt.addRow(hostId, "BUILDSTRING", VoltDB.instance().getBuildString());
    // version
    vt.addRow(hostId, "VERSION", VoltDB.instance().getVersionString());
    // catalog path
    String path = VoltDB.instance().getConfig().m_pathToCatalog;
    if (path != null && !path.startsWith("http"))
        path = (new File(path)).getAbsolutePath();
    vt.addRow(hostId, "CATALOG", path);
    // deployment path
    path = VoltDB.instance().getConfig().m_pathToDeployment;
    if (path != null && !path.startsWith("http"))
        path = (new File(path)).getAbsolutePath();
    vt.addRow(hostId, "DEPLOYMENT", path);
    String cluster_state = VoltDB.instance().getMode().toString();
    vt.addRow(hostId, "CLUSTERSTATE", cluster_state);
    // INITIALIZED, used by VEM to determine the spinny icon state.
    org.voltdb.OperationMode mode = VoltDB.instance().getMode();
    String areInitialized = Boolean.toString(!VoltDB.instance().rejoining() && (mode == org.voltdb.OperationMode.RUNNING || mode == org.voltdb.OperationMode.PAUSED));
    vt.addRow(hostId, "INITIALIZED", areInitialized);
    String replication_role = VoltDB.instance().getReplicationRole().toString();
    vt.addRow(hostId, "REPLICATIONROLE", replication_role);
    vt.addRow(hostId, "LASTCATALOGUPDATETXNID", Long.toString(VoltDB.instance().getCatalogContext().m_transactionId));
    vt.addRow(hostId, "CATALOGCRC", Long.toString(VoltDB.instance().getCatalogContext().getCatalogCRC()));
    vt.addRow(hostId, "IV2ENABLED", "true");
    long startTimeMs = VoltDB.instance().getHostMessenger().getInstanceId().getTimestamp();
    vt.addRow(hostId, "STARTTIME", Long.toString(startTimeMs));
    vt.addRow(hostId, "UPTIME", MiscUtils.formatUptime(VoltDB.instance().getClusterUptime()));
    SocketHubAppender hubAppender = (SocketHubAppender) Logger.getRootLogger().getAppender("hub");
    int port = 0;
    if (hubAppender != null)
        port = hubAppender.getPort();
    vt.addRow(hostId, "LOG4JPORT", Integer.toString(port));
    //Add license information
    if (MiscUtils.isPro()) {
        vt.addRow(hostId, "LICENSE", VoltDB.instance().getLicenseInformation());
    }
    populatePartitionGroups(hostId, vt);
    // root path
    vt.addRow(hostId, "VOLTDBROOT", VoltDB.instance().getVoltDBRootPath());
    vt.addRow(hostId, "FULLCLUSTERSIZE", Integer.toString(VoltDB.instance().getCatalogContext().getClusterSettings().hostcount()));
    vt.addRow(hostId, "CLUSTERID", Integer.toString(VoltDB.instance().getCatalogContext().getCluster().getDrclusterid()));
    return vt;
}
Also used : UnknownHostException(java.net.UnknownHostException) SocketHubAppender(org.apache.log4j.net.SocketHubAppender) JSONArray(org.json_voltpatches.JSONArray) JSONException(org.json_voltpatches.JSONException) VoltTable(org.voltdb.VoltTable) JSONObject(org.json_voltpatches.JSONObject) InetAddress(java.net.InetAddress) File(java.io.File)

Aggregations

File (java.io.File)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 SocketHubAppender (org.apache.log4j.net.SocketHubAppender)1 JSONArray (org.json_voltpatches.JSONArray)1 JSONException (org.json_voltpatches.JSONException)1 JSONObject (org.json_voltpatches.JSONObject)1 VoltTable (org.voltdb.VoltTable)1