Search in sources :

Example 1 with MemcachedClientConfig

use of com.zimbra.cs.account.soap.SoapProvisioning.MemcachedClientConfig in project zm-mailbox by Zimbra.

the class ProvUtil method doGetMemcachedClientConfig.

private void doGetMemcachedClientConfig(String[] args) throws ServiceException {
    List<Pair<String, Integer>> servers = getMailboxServersFromArgs(args);
    // Send command to each server.
    int longestHostname = 0;
    for (Pair<String, Integer> server : servers) {
        String hostname = server.getFirst();
        longestHostname = Math.max(longestHostname, hostname.length());
    }
    String hostnameFormat = String.format("%%-%ds", longestHostname);
    boolean consistent = true;
    String prevConf = null;
    for (Pair<String, Integer> server : servers) {
        String hostname = server.getFirst();
        int port = server.getSecond();
        try {
            SoapProvisioning sp = new SoapProvisioning();
            sp.soapSetURI(LC.zimbra_admin_service_scheme.value() + hostname + ":" + port + AdminConstants.ADMIN_SERVICE_URI);
            if (debugLevel != SoapDebugLevel.none) {
                sp.soapSetHttpTransportDebugListener(this);
            }
            if (account != null && password != null) {
                sp.soapAdminAuthenticate(account, password);
            } else if (authToken != null) {
                sp.soapAdminAuthenticate(authToken);
            } else {
                sp.soapZimbraAdminAuthenticate();
            }
            MemcachedClientConfig config = sp.getMemcachedClientConfig();
            String serverList = config.serverList != null ? config.serverList : "none";
            if (verboseMode) {
                console.printf(hostnameFormat + " => serverList=[%s], hashAlgo=%s, binaryProto=%s, expiry=%ds, timeout=%dms\n", hostname, serverList, config.hashAlgorithm, config.binaryProtocol, config.defaultExpirySeconds, config.defaultTimeoutMillis);
            } else if (config.serverList != null) {
                if (DefaultHashAlgorithm.KETAMA_HASH.toString().equals(config.hashAlgorithm)) {
                    // Don't print the default hash algorithm to keep the output clutter-free.
                    console.printf(hostnameFormat + " => %s\n", hostname, serverList);
                } else {
                    console.printf(hostnameFormat + " => %s (%S)\n", hostname, serverList, config.hashAlgorithm);
                }
            } else {
                console.printf(hostnameFormat + " => none\n", hostname);
            }
            String listAndAlgo = serverList + "/" + config.hashAlgorithm;
            if (prevConf == null) {
                prevConf = listAndAlgo;
            } else if (!prevConf.equals(listAndAlgo)) {
                consistent = false;
            }
        } catch (ServiceException e) {
            console.printf(hostnameFormat + " => ERROR: unable to get configuration\n", hostname);
            if (verboseMode) {
                e.printStackTrace(console);
            }
        }
    }
    if (!consistent) {
        console.println("Inconsistency detected!");
    }
}
Also used : ServiceException(com.zimbra.common.service.ServiceException) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) Pair(com.zimbra.common.util.Pair) MemcachedClientConfig(com.zimbra.cs.account.soap.SoapProvisioning.MemcachedClientConfig)

Aggregations

ServiceException (com.zimbra.common.service.ServiceException)1 Pair (com.zimbra.common.util.Pair)1 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)1 MemcachedClientConfig (com.zimbra.cs.account.soap.SoapProvisioning.MemcachedClientConfig)1