Search in sources :

Example 36 with SB

use of org.apache.ignite.internal.util.typedef.internal.SB in project ignite by apache.

the class IgniteKernal method ackRemoteManagement.

/**
 * Acks remote management.
 */
private void ackRemoteManagement() {
    assert log != null;
    if (!log.isInfoEnabled())
        return;
    SB sb = new SB();
    sb.a("Remote Management [");
    boolean on = isJmxRemoteEnabled();
    sb.a("restart: ").a(onOff(isRestartEnabled())).a(", ");
    sb.a("REST: ").a(onOff(isRestEnabled())).a(", ");
    sb.a("JMX (");
    sb.a("remote: ").a(onOff(on));
    if (on) {
        sb.a(", ");
        sb.a("port: ").a(System.getProperty("com.sun.management.jmxremote.port", "<n/a>")).a(", ");
        sb.a("auth: ").a(onOff(Boolean.getBoolean("com.sun.management.jmxremote.authenticate"))).a(", ");
        // By default SSL is enabled, that's why additional check for null is needed.
        // See http://docs.oracle.com/javase/6/docs/technotes/guides/management/agent.html
        sb.a("ssl: ").a(onOff(Boolean.getBoolean("com.sun.management.jmxremote.ssl") || System.getProperty("com.sun.management.jmxremote.ssl") == null));
    }
    sb.a(")");
    sb.a(']');
    log.info(sb.toString());
}
Also used : SB(org.apache.ignite.internal.util.typedef.internal.SB)

Example 37 with SB

use of org.apache.ignite.internal.util.typedef.internal.SB in project ignite by apache.

the class IgniteKernal method fillNodeAttributes.

/**
 * Creates attributes map and fills it in.
 *
 * @param notifyEnabled Update notifier flag.
 * @throws IgniteCheckedException thrown if was unable to set up attribute.
 */
@SuppressWarnings({ "SuspiciousMethodCalls", "unchecked", "TypeMayBeWeakened" })
private void fillNodeAttributes(boolean notifyEnabled) throws IgniteCheckedException {
    ctx.addNodeAttribute(ATTR_DATA_STREAMER_POOL_SIZE, configuration().getDataStreamerThreadPoolSize());
    final String[] incProps = cfg.getIncludeProperties();
    try {
        // Stick all environment settings into node attributes.
        for (Map.Entry<String, String> sysEntry : System.getenv().entrySet()) {
            String name = sysEntry.getKey();
            if (incProps == null || U.containsStringArray(incProps, name, true) || U.isVisorNodeStartProperty(name) || U.isVisorRequiredProperty(name))
                ctx.addNodeAttribute(name, sysEntry.getValue());
        }
        if (log.isDebugEnabled())
            log.debug("Added environment properties to node attributes.");
    } catch (SecurityException e) {
        throw new IgniteCheckedException("Failed to add environment properties to node attributes due to " + "security violation: " + e.getMessage());
    }
    try {
        // identical names from environment properties.
        for (Map.Entry<Object, Object> e : snapshot().entrySet()) {
            String key = (String) e.getKey();
            if (incProps == null || U.containsStringArray(incProps, key, true) || U.isVisorRequiredProperty(key)) {
                Object val = ctx.nodeAttribute(key);
                if (val != null && !val.equals(e.getValue()))
                    U.warn(log, "System property will override environment variable with the same name: " + key);
                ctx.addNodeAttribute(key, e.getValue());
            }
        }
        ctx.addNodeAttribute(IgniteNodeAttributes.ATTR_UPDATE_NOTIFIER_ENABLED, notifyEnabled);
        if (log.isDebugEnabled())
            log.debug("Added system properties to node attributes.");
    } catch (SecurityException e) {
        throw new IgniteCheckedException("Failed to add system properties to node attributes due to security " + "violation: " + e.getMessage());
    }
    // Add local network IPs and MACs.
    // Exclude loopbacks.
    String ips = F.concat(U.allLocalIps(), ", ");
    // Only enabled network interfaces.
    String macs = F.concat(U.allLocalMACs(), ", ");
    // Ack network context.
    if (log.isInfoEnabled()) {
        log.info("Non-loopback local IPs: " + (F.isEmpty(ips) ? "N/A" : ips));
        log.info("Enabled local MACs: " + (F.isEmpty(macs) ? "N/A" : macs));
    }
    // Warn about loopback.
    if (ips.isEmpty() && macs.isEmpty())
        U.warn(log, "Ignite is starting on loopback address... Only nodes on the same physical " + "computer can participate in topology.", "Ignite is starting on loopback address...");
    // Stick in network context into attributes.
    add(ATTR_IPS, (ips.isEmpty() ? "" : ips));
    add(ATTR_MACS, (macs.isEmpty() ? "" : macs));
    // Stick in some system level attributes
    add(ATTR_JIT_NAME, U.getCompilerMx() == null ? "" : U.getCompilerMx().getName());
    add(ATTR_BUILD_VER, VER_STR);
    add(ATTR_BUILD_DATE, BUILD_TSTAMP_STR);
    add(ATTR_MARSHALLER, cfg.getMarshaller().getClass().getName());
    add(ATTR_MARSHALLER_USE_DFLT_SUID, getBoolean(IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID, OptimizedMarshaller.USE_DFLT_SUID));
    add(ATTR_LATE_AFFINITY_ASSIGNMENT, cfg.isLateAffinityAssignment());
    if (cfg.getMarshaller() instanceof BinaryMarshaller) {
        add(ATTR_MARSHALLER_COMPACT_FOOTER, cfg.getBinaryConfiguration() == null ? BinaryConfiguration.DFLT_COMPACT_FOOTER : cfg.getBinaryConfiguration().isCompactFooter());
        add(ATTR_MARSHALLER_USE_BINARY_STRING_SER_VER_2, getBoolean(IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2, BinaryUtils.USE_STR_SERIALIZATION_VER_2));
    }
    add(ATTR_USER_NAME, System.getProperty("user.name"));
    add(ATTR_IGNITE_INSTANCE_NAME, igniteInstanceName);
    add(ATTR_PEER_CLASSLOADING, cfg.isPeerClassLoadingEnabled());
    add(ATTR_DEPLOYMENT_MODE, cfg.getDeploymentMode());
    add(ATTR_LANG_RUNTIME, getLanguage());
    add(ATTR_JVM_PID, U.jvmPid());
    add(ATTR_CLIENT_MODE, cfg.isClientMode());
    add(ATTR_CONSISTENCY_CHECK_SKIPPED, getBoolean(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK));
    if (cfg.getConsistentId() != null)
        add(ATTR_NODE_CONSISTENT_ID, cfg.getConsistentId());
    // Build a string from JVM arguments, because parameters with spaces are split.
    SB jvmArgs = new SB(512);
    for (String arg : U.jvmArgs()) {
        if (arg.startsWith("-"))
            jvmArgs.a("@@@");
        else
            jvmArgs.a(' ');
        jvmArgs.a(arg);
    }
    // Add it to attributes.
    add(ATTR_JVM_ARGS, jvmArgs.toString());
    // Check daemon system property and override configuration if it's set.
    if (isDaemon())
        add(ATTR_DAEMON, "true");
    // node attribute won't be set.
    if (isJmxRemoteEnabled()) {
        String portStr = System.getProperty("com.sun.management.jmxremote.port");
        if (portStr != null)
            try {
                add(ATTR_JMX_PORT, Integer.parseInt(portStr));
            } catch (NumberFormatException ignore) {
            // No-op.
            }
    }
    // Whether restart is enabled and stick the attribute.
    add(ATTR_RESTART_ENABLED, Boolean.toString(isRestartEnabled()));
    // Save port range, port numbers will be stored by rest processor at runtime.
    if (cfg.getConnectorConfiguration() != null)
        add(ATTR_REST_PORT_RANGE, cfg.getConnectorConfiguration().getPortRange());
    // Save data storage configuration.
    addDataStorageConfigurationAttributes();
    // Save transactions configuration.
    add(ATTR_TX_CONFIG, cfg.getTransactionConfiguration());
    // Stick in SPI versions and classes attributes.
    addSpiAttributes(cfg.getCollisionSpi());
    addSpiAttributes(cfg.getDiscoverySpi());
    addSpiAttributes(cfg.getFailoverSpi());
    addSpiAttributes(cfg.getCommunicationSpi());
    addSpiAttributes(cfg.getEventStorageSpi());
    addSpiAttributes(cfg.getCheckpointSpi());
    addSpiAttributes(cfg.getLoadBalancingSpi());
    addSpiAttributes(cfg.getDeploymentSpi());
    // Set user attributes for this node.
    if (cfg.getUserAttributes() != null) {
        for (Map.Entry<String, ?> e : cfg.getUserAttributes().entrySet()) {
            if (ctx.hasNodeAttribute(e.getKey()))
                U.warn(log, "User or internal attribute has the same name as environment or system " + "property and will take precedence: " + e.getKey());
            ctx.addNodeAttribute(e.getKey(), e.getValue());
        }
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) Map(java.util.Map) HashMap(java.util.HashMap) SB(org.apache.ignite.internal.util.typedef.internal.SB)

Example 38 with SB

use of org.apache.ignite.internal.util.typedef.internal.SB in project ignite by apache.

the class PdsConsistentIdProcessor method padStart.

/**
 * Pad start of string with provided character.
 *
 * @param str sting to pad.
 * @param minLength expected length.
 * @param padChar padding character.
 * @return padded string.
 */
private static String padStart(String str, int minLength, char padChar) {
    A.notNull(str, "String should not be empty");
    if (str.length() >= minLength)
        return str;
    final SB sb = new SB(minLength);
    for (int i = str.length(); i < minLength; ++i) sb.a(padChar);
    sb.a(str);
    return sb.toString();
}
Also used : SB(org.apache.ignite.internal.util.typedef.internal.SB)

Example 39 with SB

use of org.apache.ignite.internal.util.typedef.internal.SB in project ignite by apache.

the class AbstractSchemaSelfTest method dynamicIndexCreate.

/**
     * Synchronously create index.
     *
     * @param node Ignite node.
     * @param cacheName Cache name.
     * @param tblName Table name.
     * @param idx Index.
     * @param ifNotExists When set to true operation will fail if index already exists.
     * @throws Exception If failed.
     */
protected void dynamicIndexCreate(Ignite node, String cacheName, String tblName, QueryIndex idx, boolean ifNotExists) throws Exception {
    GridStringBuilder sql = new SB("CREATE INDEX ").a(ifNotExists ? "IF NOT EXISTS " : "").a(idx.getName()).a(" ON ").a(tblName).a(" (");
    boolean first = true;
    for (Map.Entry<String, Boolean> fieldEntry : idx.getFields().entrySet()) {
        if (first)
            first = false;
        else
            sql.a(", ");
        String name = fieldEntry.getKey();
        boolean asc = fieldEntry.getValue();
        sql.a(name).a(" ").a(asc ? "ASC" : "DESC");
    }
    sql.a(')');
    executeSql(node, cacheName, sql.toString());
}
Also used : GridStringBuilder(org.apache.ignite.internal.util.GridStringBuilder) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) SB(org.apache.ignite.internal.util.typedef.internal.SB)

Example 40 with SB

use of org.apache.ignite.internal.util.typedef.internal.SB in project ignite by apache.

the class GridOffHeapSnapTreeMap method print.

/**
     * @param node Node.
     * @param s String builders.
     * @param level Level.
     * @param offset Offset.
     * @return Length.
     */
private int print(long node, ArrayList<SB> s, int level, int offset) {
    if (node == 0)
        return s.get(level - 1).length();
    SB sb = s.size() <= level ? null : s.get(level);
    if (sb == null) {
        sb = new SB();
        s.add(level, sb);
    }
    int o = Math.max(print(left(node), s, level + 1, offset), offset);
    String v = print0(node);
    while (sb.length() < o) sb.a(' ');
    sb.a(v);
    return print(right(node), s, level + 1, o + v.length());
}
Also used : SB(org.apache.ignite.internal.util.typedef.internal.SB)

Aggregations

SB (org.apache.ignite.internal.util.typedef.internal.SB)70 Map (java.util.Map)10 HashMap (java.util.HashMap)7 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 LinkedHashMap (java.util.LinkedHashMap)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 GridStringBuilder (org.apache.ignite.internal.util.GridStringBuilder)4 InputStreamReader (java.io.InputStreamReader)3 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)3 IgfsLogger (org.apache.ignite.internal.igfs.common.IgfsLogger)3 InputStream (java.io.InputStream)2 InterruptedIOException (java.io.InterruptedIOException)2 LineNumberReader (java.io.LineNumberReader)2 URL (java.net.URL)2 URLConnection (java.net.URLConnection)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 UUID (java.util.UUID)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2