Java Code Examples for javax.management.openmbean.SimpleType

The following are top voted examples for showing how to use javax.management.openmbean.SimpleType. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: openjdk-jdk10   File: TypeVersionMapper.java   Source Code and License 6 votes vote down vote up
private ArrayType<?> getVersionedArrayType(ArrayType<?> type, String version)
    throws OpenDataException
{
    if (type.isPrimitiveArray()) {
        return type;
    }
    OpenType<?> ot = getVersionedType(
        type.getElementOpenType(),
        version
    );
    if (ot instanceof SimpleType) {
        return new ArrayType<>((SimpleType<?>)ot, type.isPrimitiveArray());
    } else {
        return new ArrayType<>(type.getDimension(), ot);
    }
}
 
Example 2
Project: tqdev-metrics   File: JmxReporter.java   Source Code and License 6 votes vote down vote up
@Override
public MBeanInfo getMBeanInfo() {

	ArrayList<OpenMBeanAttributeInfoSupport> attributes = new ArrayList<>();

	attributes.add(new OpenMBeanAttributeInfoSupport("enabled", "enabled", SimpleType.BOOLEAN, true, true, true));
	for (String type : registry.getTypes()) {
		attributes.add(new OpenMBeanAttributeInfoSupport(type, type, getCompositeType(type), true, false, false));
	}

	OpenMBeanParameterInfo[] params = new OpenMBeanParameterInfoSupport[0];
	OpenMBeanOperationInfoSupport reset = new OpenMBeanOperationInfoSupport("reset", "Reset all Metrics", params,
			SimpleType.VOID, MBeanOperationInfo.ACTION);

	OpenMBeanInfoSupport PSOMBInfo = new OpenMBeanInfoSupport(this.getClass().getName(), description,
			attributes.toArray(new OpenMBeanAttributeInfoSupport[0]), new OpenMBeanConstructorInfoSupport[0],
			new OpenMBeanOperationInfoSupport[] { reset }, new MBeanNotificationInfo[0]);

	return PSOMBInfo;
}
 
Example 3
Project: hashsdn-controller   File: JavaAttribute.java   Source Code and License 6 votes vote down vote up
private OpenType<?> getCompositeType(final Type baseType, final TypeDefinition<?> baseTypeDefinition) {

        final SimpleType<?> innerItemType = SimpleTypeResolver.getSimpleType(baseType);
        final String innerItemName = this.typeProviderWrapper.getJMXParamForBaseType(baseTypeDefinition);

        final String[] itemNames = new String[]{innerItemName};
        final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();

        final OpenType<?>[] itemTypes = new OpenType[]{innerItemType};
        try {
            return new CompositeType(getUpperCaseCammelCase(), description, itemNames, itemNames, itemTypes);
        } catch (final OpenDataException e) {
            throw new RuntimeException("Unable to create " + CompositeType.class + " with inner element of type "
                    + itemTypes, e);
        }
    }
 
Example 4
Project: openjdk9   File: GarbageCollectionNotifInfoCompositeData.java   Source Code and License 6 votes vote down vote up
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
                SimpleType.STRING,
                SimpleType.STRING,
                SimpleType.STRING,
                GcInfoCompositeData.getBaseGcInfoCompositeType()
            };
            baseGcNotifInfoCompositeType =
                new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
                                  "CompositeType for Base GarbageCollectionNotificationInfo",
                                  gcNotifInfoItemNames,
                                  gcNotifInfoItemNames,
                                  baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw new RuntimeException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
 
Example 5
Project: openjdk9   File: TypeVersionMapper.java   Source Code and License 6 votes vote down vote up
private ArrayType<?> getVersionedArrayType(ArrayType<?> type, String version)
    throws OpenDataException
{
    if (type.isPrimitiveArray()) {
        return type;
    }
    OpenType<?> ot = getVersionedType(
        type.getElementOpenType(),
        version
    );
    if (ot instanceof SimpleType) {
        return new ArrayType<>((SimpleType<?>)ot, type.isPrimitiveArray());
    } else {
        return new ArrayType<>(type.getDimension(), ot);
    }
}
 
Example 6
Project: jdk8u_jdk   File: GarbageCollectionNotifInfoCompositeData.java   Source Code and License 6 votes vote down vote up
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
                SimpleType.STRING,
                SimpleType.STRING,
                SimpleType.STRING,
                GcInfoCompositeData.getBaseGcInfoCompositeType()
            };
            baseGcNotifInfoCompositeType =
                new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
                                  "CompositeType for Base GarbageCollectionNotificationInfo",
                                  gcNotifInfoItemNames,
                                  gcNotifInfoItemNames,
                                  baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw Util.newException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
 
Example 7
Project: lookaside_java-1.8.0-openjdk   File: GarbageCollectionNotifInfoCompositeData.java   Source Code and License 6 votes vote down vote up
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
                SimpleType.STRING,
                SimpleType.STRING,
                SimpleType.STRING,
                GcInfoCompositeData.getBaseGcInfoCompositeType()
            };
            baseGcNotifInfoCompositeType =
                new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
                                  "CompositeType for Base GarbageCollectionNotificationInfo",
                                  gcNotifInfoItemNames,
                                  gcNotifInfoItemNames,
                                  baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw Util.newException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
 
Example 8
Project: scylla-jmx   File: FailureDetector.java   Source Code and License 6 votes vote down vote up
@Override
public TabularData getPhiValues() throws OpenDataException {
    final CompositeType ct = new CompositeType("Node", "Node", new String[] { "Endpoint", "PHI" },
            new String[] { "IP of the endpoint", "PHI value" },
            new OpenType[] { SimpleType.STRING, SimpleType.DOUBLE });
    final TabularDataSupport results = new TabularDataSupport(
            new TabularType("PhiList", "PhiList", ct, new String[] { "Endpoint" }));
    final JsonArray arr = client.getJsonArray("/failure_detector/endpoint_phi_values");

    for (JsonValue v : arr) {
        JsonObject o = (JsonObject) v;
        String endpoint = o.getString("endpoint");
        double phi = Double.parseDouble(o.getString("phi"));

        if (phi != Double.MIN_VALUE) {
            // returned values are scaled by PHI_FACTOR so that the are on
            // the same scale as PhiConvictThreshold
            final CompositeData data = new CompositeDataSupport(ct, new String[] { "Endpoint", "PHI" },
                    new Object[] { endpoint, phi * PHI_FACTOR });
            results.put(data);
        }
    }

    return results;
}
 
Example 9
Project: cacheonix-core   File: HttpAdaptor.java   Source Code and License 6 votes vote down vote up
public TestClass(String str, URL url)
{
   this.str = str;
   this.url = url;
   list.add("a");
   list.add("b");
   list.add("c");
   map.put("1", "a");
   map.put("2", "b");
   map.put("3", "c");
   try
   {
      CompositeType type = new CompositeType("My type",
                                             "My type",
                                             new String[]{"item1", "item2"},
                                             new String[]{"item1", "item2"},
                                             new OpenType[]{SimpleType.STRING, SimpleType.STRING});
      compositeData = new CompositeDataSupport(type, new String[]{"item1", "item2"}, new Object[]{"item value 1", "item value 2"});
   }
   catch (OpenDataException e)
   {
      e.printStackTrace();
   }

}
 
Example 10
Project: parfait   File: JmxView.java   Source Code and License 6 votes vote down vote up
private OpenType<?> getJmxType(Class<?> type) {
    if (type == Boolean.class) {
        return SimpleType.BOOLEAN;
    } else if (type == Integer.class || type == AtomicInteger.class) {
        return SimpleType.INTEGER;
    } else if (type == Long.class || type == AtomicLong.class) {
        return SimpleType.LONG;
    } else if (type == Double.class) {
        return SimpleType.DOUBLE;
    } else if (type == String.class) {
        return SimpleType.STRING;
    } else {
        throw new UnsupportedOperationException(
                "Don't know how to process Monitorable of type [" + type + "]");
    }
}
 
Example 11
Project: acs-aem-samples   File: SampleContentReplicationHarnessImpl.java   Source Code and License 6 votes vote down vote up
@Override
// MBean method
// @Description is set at the interface level
public final CompositeDataSupport getThrottleConfig() throws OpenDataException {

    final CompositeType throttleConfigurationType = new CompositeType(
            "Throttle Configuration",
            "Throttle Configuration",
            new String[]{"Throttle (in ms)", "Batch size"},
            new String[]{"Throttle (in ms)", "Batch size"},
            new OpenType[]{SimpleType.INTEGER, SimpleType.INTEGER}
    );

    final Map<String, Object> data = new HashMap<String, Object>();
    data.put("Throttle (in ms)", this.throttle.get());
    data.put("Batch size", this.batchSize.get());
    return new CompositeDataSupport(throttleConfigurationType, data);
}
 
Example 12
Project: infobip-open-jdk-8   File: GarbageCollectionNotifInfoCompositeData.java   Source Code and License 6 votes vote down vote up
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
                SimpleType.STRING,
                SimpleType.STRING,
                SimpleType.STRING,
                GcInfoCompositeData.getBaseGcInfoCompositeType()
            };
            baseGcNotifInfoCompositeType =
                new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
                                  "CompositeType for Base GarbageCollectionNotificationInfo",
                                  gcNotifInfoItemNames,
                                  gcNotifInfoItemNames,
                                  baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw Util.newException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
 
Example 13
Project: jdk8u-dev-jdk   File: GarbageCollectionNotifInfoCompositeData.java   Source Code and License 6 votes vote down vote up
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
                SimpleType.STRING,
                SimpleType.STRING,
                SimpleType.STRING,
                GcInfoCompositeData.getBaseGcInfoCompositeType()
            };
            baseGcNotifInfoCompositeType =
                new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
                                  "CompositeType for Base GarbageCollectionNotificationInfo",
                                  gcNotifInfoItemNames,
                                  gcNotifInfoItemNames,
                                  baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw Util.newException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
 
Example 14
Project: datakernel   File: AttributeNodeForSimpleType.java   Source Code and License 6 votes vote down vote up
private static SimpleType<?> simpleTypeOf(Class<?> clazz) throws IllegalArgumentException {
	if (clazz == boolean.class || clazz == Boolean.class) {
		return SimpleType.BOOLEAN;
	} else if (clazz == byte.class || clazz == Byte.class) {
		return SimpleType.BYTE;
	} else if (clazz == short.class || clazz == Short.class) {
		return SimpleType.SHORT;
	} else if (clazz == char.class || clazz == Character.class) {
		return SimpleType.CHARACTER;
	} else if (clazz == int.class || clazz == Integer.class) {
		return SimpleType.INTEGER;
	} else if (clazz == long.class || clazz == Long.class) {
		return SimpleType.LONG;
	} else if (clazz == float.class || clazz == Float.class) {
		return SimpleType.FLOAT;
	} else if (clazz == double.class || clazz == Double.class) {
		return SimpleType.DOUBLE;
	} else if (clazz == String.class) {
		return SimpleType.STRING;
	} else {
		throw new IllegalArgumentException("There is no SimpleType for " + clazz.getName());
	}
}
 
Example 15
Project: datakernel   File: ExceptionStatsTest.java   Source Code and License 6 votes vote down vote up
@Before
public void before() throws OpenDataException {
	exceptionDetailsItemNames = new String[]{
			"lastException",
			"lastExceptionCausedObject",
			"lastExceptionStackTrace",
			"lastExceptionTimestamp",
			"totalExceptions"
	};

	exceptionDetailsItemTypes = new OpenType<?>[]{
			SimpleType.STRING,
			SimpleType.STRING,
			new ArrayType<>(1, SimpleType.STRING),
			SimpleType.LONG,
			SimpleType.INTEGER
	};
}
 
Example 16
Project: wildfly-core   File: LegacyTypeConverterUnitTestCase.java   Source Code and License 6 votes vote down vote up
@Test
public void testJsonObject() throws Exception {
    ModelNode description = createDescription(ModelType.OBJECT);

    TypeConverter converter = getConverter(description);

    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());

    ModelNode node = new ModelNode();
    node.get("long").set(5L);
    node.get("string").set("Value");
    node.get("a", "b").set(true);
    node.get("c", "d").set(40);

    String json = node.toJSONString(false);
    String data = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(json, data);

    Assert.assertEquals(ModelNode.fromJSONString(json), converter.toModelNode(data));
}
 
Example 17
Project: olat   File: ClusterEventBus.java   Source Code and License 6 votes vote down vote up
private CompositeDataSupport propertiesToCompositeData(final Map<String, ?> properties) {
    // try {
    try {
        final String[] keys = properties.keySet().toArray(new String[0]);
        final OpenType[] itemTypes = new OpenType[keys.length];
        for (int i = 0; i < itemTypes.length; i++) {
            itemTypes[i] = SimpleType.STRING;
        }
        CompositeType propsType;
        propsType = new CompositeType("Properties type", "properties", keys, keys, itemTypes);
        final CompositeDataSupport propsData = new CompositeDataSupport(propsType, properties);
        return propsData;
    } catch (final OpenDataException e) {
        throw new AssertException("problem with jmx data generation", e);
    }
}
 
Example 18
Project: olat   File: ClusterEventBus.java   Source Code and License 6 votes vote down vote up
private CompositeDataSupport propertiesToCompositeData(final Map<String, ?> properties) {
    // try {
    try {
        final String[] keys = properties.keySet().toArray(new String[0]);
        final OpenType[] itemTypes = new OpenType[keys.length];
        for (int i = 0; i < itemTypes.length; i++) {
            itemTypes[i] = SimpleType.STRING;
        }
        CompositeType propsType;
        propsType = new CompositeType("Properties type", "properties", keys, keys, itemTypes);
        final CompositeDataSupport propsData = new CompositeDataSupport(propsType, properties);
        return propsData;
    } catch (final OpenDataException e) {
        throw new AssertException("problem with jmx data generation", e);
    }
}
 
Example 19
Project: bagri   File: JMXUtils.java   Source Code and License 6 votes vote down vote up
private static OpenType getOpenType(Object value) throws OpenDataException {
    if (value == null) {
        return SimpleType.VOID;
    }

    //if (OpenType.ALLOWED_CLASSNAMES_LIST.contains(name)) {
    int dim = 0;
    Class<?> cls = value.getClass();
    while (cls.isArray()) {
    	cls = value.getClass().getComponentType();
    	dim++;
    }
	SimpleType<?> type = getTypeForName(cls.getName());
	if (type != null && dim > 0) {
		if (cls.isPrimitive() && dim == 1) {
    		return new ArrayType<>(type, true);
		}
		return new ArrayType<>(dim, type);
	}
   	return type;
}
 
Example 20
Project: openjdk-source-code-learn   File: GarbageCollectionNotifInfoCompositeData.java   Source Code and License 6 votes vote down vote up
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType[] baseGcNotifInfoItemTypes = new OpenType[] {
                SimpleType.STRING,
                SimpleType.STRING,
                SimpleType.STRING,
                GcInfoCompositeData.getBaseGcInfoCompositeType()
            };
            baseGcNotifInfoCompositeType =
                new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
                                  "CompositeType for Base GarbageCollectionNotificationInfo",
                                  gcNotifInfoItemNames,
                                  gcNotifInfoItemNames,
                                  baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw Util.newException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
 
Example 21
Project: wildfly-core   File: LegacyTypeConverterUnitTestCase.java   Source Code and License 6 votes vote down vote up
@Test
public void testUndefinedTypeConverter() {
    TypeConverter converter = getConverter(new ModelNode());
    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());

    ModelNode node = new ModelNode();
    // BES 2013/01/10 This uses BigInteger; I'm not sure why. But use a value > Long.MAX_VALUE
    // so the json parser won't convert it down to a long or int resulting in a different value
    // See AS7-4913
    // Likely BigInteger was used *because of* the problem discussed in AS7-4913
    node.get("abc").set(new BigInteger(String.valueOf(Long.MAX_VALUE) + "0"));
    node.get("def").set(false);
    node.protect();

    String json = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(node, ModelNode.fromJSONString(json));
    Assert.assertEquals(json, assertCast(String.class, converter.fromModelNode(node)));
    assertToArray(converter, json);
}
 
Example 22
Project: wildfly-core   File: ExpressionTypeConverterUnitTestCase.java   Source Code and License 6 votes vote down vote up
@Test
public void testByteArrayObject() throws Exception {
    ModelNode description = createDescription(ModelType.OBJECT, ModelType.BYTES);
    TypeConverter converter = getConverter(description);

    assertMapType(assertCast(TabularType.class, converter.getOpenType()), SimpleType.STRING, ArrayType.getPrimitiveArrayType(byte[].class));

    ModelNode node = new ModelNode();
    node.get("one").set(new byte[] {1,2});
    node.get("two").set(new byte[] {3,4});

    TabularData tabularData = assertCast(TabularData.class, converter.fromModelNode(node));
    Assert.assertEquals(2, tabularData.size());
    Assert.assertTrue(Arrays.equals(new byte[] {1,2}, (byte[])tabularData.get(new Object[] {"one"}).get("value")));
    Assert.assertTrue(Arrays.equals(new byte[] {3,4}, (byte[])tabularData.get(new Object[] {"two"}).get("value")));

    //Allow plain map as well? Yeah why not!
    Map<String, byte[]> map = new HashMap<String, byte[]>();
    map.put("one", new byte[] {1,2});
    map.put("two", new byte[] {3,4});
    Assert.assertEquals(node, converter.toModelNode(map));
}
 
Example 23
Project: OLD-OpenJDK8   File: GarbageCollectionNotifInfoCompositeData.java   Source Code and License 6 votes vote down vote up
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
    if (baseGcNotifInfoCompositeType == null) {
        try {
            OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] {
                SimpleType.STRING,
                SimpleType.STRING,
                SimpleType.STRING,
                GcInfoCompositeData.getBaseGcInfoCompositeType()
            };
            baseGcNotifInfoCompositeType =
                new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType",
                                  "CompositeType for Base GarbageCollectionNotificationInfo",
                                  gcNotifInfoItemNames,
                                  gcNotifInfoItemNames,
                                  baseGcNotifInfoItemTypes);
        } catch (OpenDataException e) {
            // shouldn't reach here
            throw Util.newException(e);
        }
    }
    return baseGcNotifInfoCompositeType;
}
 
Example 24
Project: cn1   File: ManagementUtils.java   Source Code and License 6 votes vote down vote up
/**
 * @return an instance of {@link CompositeType}for the
 *         {@link MemoryNotificationInfo}class.
 */
private static CompositeType getMemoryNotificationInfoCompositeType() {
    if (MEMORYNOTIFICATIONINFO_COMPOSITETYPE == null) {
        String[] typeNames = { "poolName", "usage", "count" };
        String[] typeDescs = { "poolName", "usage", "count" };
        OpenType[] typeTypes = { SimpleType.STRING,
                getMemoryUsageCompositeType(), SimpleType.LONG };
        try {
            MEMORYNOTIFICATIONINFO_COMPOSITETYPE = new CompositeType(
                    MemoryNotificationInfo.class.getName(),
                    MemoryNotificationInfo.class.getName(), typeNames,
                    typeDescs, typeTypes);
        } catch (OpenDataException e) {
            if (ManagementUtils.VERBOSE_MODE) {
                e.printStackTrace(System.err);
            }// end if
        }
    }
    return MEMORYNOTIFICATIONINFO_COMPOSITETYPE;
}
 
Example 25
Project: cn1   File: ManagementUtils.java   Source Code and License 6 votes vote down vote up
/**
 * @return an instance of {@link CompositeType}for the
 *         {@link StackTraceElement}class.
 */
private static CompositeType getStackTraceElementCompositeType() {
    if (STACKTRACEELEMENT_COMPOSITETYPE == null) {
        String[] typeNames = { "className", "methodName", "fileName",
                "lineNumber", "nativeMethod" };
        String[] typeDescs = { "className", "methodName", "fileName",
                "lineNumber", "nativeMethod" };
        OpenType[] typeTypes = { SimpleType.STRING, SimpleType.STRING,
                SimpleType.STRING, SimpleType.INTEGER, SimpleType.BOOLEAN };
        try {
            STACKTRACEELEMENT_COMPOSITETYPE = new CompositeType(
                    StackTraceElement.class.getName(),
                    StackTraceElement.class.getName(), typeNames,
                    typeDescs, typeTypes);
        } catch (OpenDataException e) {
            if (ManagementUtils.VERBOSE_MODE) {
                e.printStackTrace(System.err);
            }// end if
        }
    }
    return STACKTRACEELEMENT_COMPOSITETYPE;
}
 
Example 26
Project: wildfly-core   File: LegacyTypeConverterUnitTestCase.java   Source Code and License 6 votes vote down vote up
@Test
public void testPropertyTypeExpressionConverter() throws OperationFailedException {
    ModelNode description = createDescription(ModelType.PROPERTY);
    TypeConverter converter = getConverter(description);

    ModelNode node = new ModelNode();
    node.set("name", "${this.should.not.exist.!!!!!:value}");
    node.protect();

    ModelNode expected = ExpressionResolver.TEST_RESOLVER.resolveExpressions(node.clone());

    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());
    String dmr = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(expected, ModelNode.fromString(dmr));
    Assert.assertEquals(dmr, assertCast(String.class, converter.fromModelNode(expected)));
    assertToArray(converter, dmr);
}
 
Example 27
Project: cn1   File: MemoryNotificationInfoTest.java   Source Code and License 6 votes vote down vote up
public void test_from_scenario6() throws Exception {
    String[] names = { "poolName", "usage", "count" };
    Object[] values = { "TestPoolName", new Long(1), new Long(42) };
    OpenType[] types = { SimpleType.STRING, SimpleType.LONG,
            SimpleType.LONG };

    CompositeType compositeType = getCompositeType(names, types);
    CompositeData data = new CompositeDataSupport(compositeType, names,
            values);
    try {
        MemoryNotificationInfo.from(data);
        fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // Expected
    }
}
 
Example 28
Project: cn1   File: MemoryNotificationInfoTest.java   Source Code and License 6 votes vote down vote up
public void test_from_scenario7() throws Exception {
    String[] names = { "poolName", "usage", "count" };
    Object[] values = { "TestPoolName", memoryCompositeData, "42" };
    OpenType[] types = { SimpleType.STRING, memoryUsageCompositeType,
            SimpleType.STRING };

    CompositeType compositeType = getCompositeType(names, types);
    CompositeData data = new CompositeDataSupport(compositeType, names,
            values);
    try {
        MemoryNotificationInfo.from(data);
        fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // Expected
    }
}
 
Example 29
Project: wildfly-core   File: ExpressionTypeConverterUnitTestCase.java   Source Code and License 6 votes vote down vote up
@Test
public void testSimpleTypeObjectExpressions() throws Exception {
    ModelNode description = createDescription(ModelType.OBJECT, ModelType.LONG);
    description.get(EXPRESSIONS_ALLOWED).set(true);
    TypeConverter converter = getConverter(description);

    assertMapType(assertCast(TabularType.class, converter.getOpenType()), SimpleType.STRING, SimpleType.STRING);

    ModelNode node = new ModelNode();
    node.get("one").set(new ValueExpression("${this.should.not.exist.!!!!!:1}"));
    node.get("two").set(new ValueExpression("${this.should.not.exist.!!!!!:2}"));

    TabularData tabularData = assertCast(TabularData.class, converter.fromModelNode(node));
    Assert.assertEquals(2, tabularData.size());
    Assert.assertEquals("${this.should.not.exist.!!!!!:1}", tabularData.get(new Object[] {"one"}).get("value"));
    Assert.assertEquals("${this.should.not.exist.!!!!!:2}", tabularData.get(new Object[] {"two"}).get("value"));

    Assert.assertEquals(node, converter.toModelNode(tabularData));
}
 
Example 30
Project: cn1   File: MemoryNotificationInfoTest.java   Source Code and License 6 votes vote down vote up
public void test_from_scenario11() throws Exception {
    String[] names = { "notPoolName", "usage", "count" };
    Object[] values = { "TestNotPoolName", memoryCompositeData,
            new Long(42) };
    OpenType[] types = { SimpleType.STRING, memoryUsageCompositeType,
            SimpleType.LONG };

    CompositeType compositeType = getCompositeType(names, types);
    CompositeData data = new CompositeDataSupport(compositeType, names,
            values);
    try {
        MemoryNotificationInfo.from(data);
        fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // Expected
    }
}
 
Example 31
Project: wildfly-core   File: ExpressionTypeConverterUnitTestCase.java   Source Code and License 6 votes vote down vote up
@Test
public void testJsonObjectInComplexValue() throws Exception {
    ModelNode description = createDescription(ModelType.OBJECT);
    ModelNode complexValueType = new ModelNode();
    complexValueType.get("value", DESCRIPTION).set("A  value");
    complexValueType.get("value", TYPE).set(ModelType.OBJECT);
    description.get(VALUE_TYPE).set(complexValueType);

    TypeConverter converter = getConverter(description);

    CompositeType type = assertCast(CompositeType.class, converter.getOpenType());
    Set<String> keys = type.keySet();
    Assert.assertEquals(1, keys.size());

    Assert.assertEquals(SimpleType.STRING, type.getType("value"));

    ModelNode node = new ModelNode();
    node.get("value", "long").set(1L);
    node.get("value", "string").set("test");

    CompositeData data = assertCast(CompositeData.class, converter.fromModelNode(node));
    Assert.assertEquals(type, data.getCompositeType());
    Assert.assertEquals(ModelNode.fromJSONString(node.toJSONString(false)), converter.toModelNode(data));

}
 
Example 32
Project: cn1   File: MemoryNotificationInfoTest.java   Source Code and License 6 votes vote down vote up
public void test_from_scenario13() throws Exception {
    String[] names = { "poolName", "usage", "count", "extention" };
    Object[] values = { "TestPoolName", memoryCompositeData, new Long(42),
            "Extention" };
    OpenType[] types = { SimpleType.STRING, memoryUsageCompositeType,
            SimpleType.LONG, SimpleType.STRING };

    CompositeType compositeType = getCompositeType(names, types);
    CompositeData data = new CompositeDataSupport(compositeType, names,
            values);
    MemoryNotificationInfo info = MemoryNotificationInfo.from(data);
    assertEquals(values[0], info.getPoolName());
    assertEquals(values[2], info.getCount());
    MemoryUsage usage = info.getUsage();
    assertEquals(1, usage.getInit());
    assertEquals(2, usage.getUsed());
    assertEquals(3, usage.getCommitted());
    assertEquals(4, usage.getMax());
}
 
Example 33
Project: cn1   File: ThreadInfoTest.java   Source Code and License 6 votes vote down vote up
private static CompositeType createGoodStackTraceElementCompositeType() {
    CompositeType result = null;
    String[] typeNames = { "className", "methodName", "fileName",
            "lineNumber", "nativeMethod" };
    String[] typeDescs = { "className", "methodName", "fileName",
            "lineNumber", "nativeMethod" };
    OpenType[] typeTypes = { SimpleType.STRING, SimpleType.STRING,
            SimpleType.STRING, SimpleType.INTEGER, SimpleType.BOOLEAN };
    try {
        result = new CompositeType(StackTraceElement.class.getName(),
                StackTraceElement.class.getName(), typeNames, typeDescs,
                typeTypes);
    } catch (OpenDataException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return result;
}
 
Example 34
Project: cn1   File: ThreadInfoTest.java   Source Code and License 6 votes vote down vote up
public void test_from_scenario2() throws Exception {
    initialValues[0] = "1";
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.STRING, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // Expected
    }
}
 
Example 35
Project: cn1   File: ThreadInfoTest.java   Source Code and License 6 votes vote down vote up
public void test_from_scenario4() throws Exception {
    initialValues[0] = null;
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}
 
Example 36
Project: cn1   File: ThreadInfoTest.java   Source Code and License 6 votes vote down vote up
public void test_from_scenario5() throws Exception {
    initialValues[1] = null;
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // Expected
    }
}
 
Example 37
Project: cn1   File: ThreadInfoTest.java   Source Code and License 6 votes vote down vote up
public void test_from_scenario6() throws Exception {
    initialValues[2] = null;
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}
 
Example 38
Project: cn1   File: ThreadInfoTest.java   Source Code and License 6 votes vote down vote up
public void test_from_scenario8() throws Exception {
    initialValues[4] = null;
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}
 
Example 39
Project: cn1   File: ThreadInfoTest.java   Source Code and License 6 votes vote down vote up
public void test_from_scenario9() throws Exception {
    initialValues[5] = null;
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}
 
Example 40
Project: cn1   File: ThreadInfoTest.java   Source Code and License 6 votes vote down vote up
public void test_from_scenario10() throws Exception {
    initialValues[6] = null;
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}
 
Example 41
Project: wildfly-core   File: LegacyTypeConverterUnitTestCase.java   Source Code and License 6 votes vote down vote up
@Test
public void testPropertyValueTypeExpressionConverter() throws Exception {
    ModelNode description = createDescription(ModelType.PROPERTY, ModelType.INT);
    TypeConverter converter = getConverter(description);

    ModelNode node = new ModelNode();
    node.set("name", "${this.should.not.exist.!!!!!:1}");
    node.protect();

    ModelNode expected = ExpressionResolver.TEST_RESOLVER.resolveExpressions(node.clone());

    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());
    String dmr = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(expected, ModelNode.fromString(dmr));
    Assert.assertEquals(dmr, assertCast(String.class, converter.fromModelNode(expected)));
    assertToArray(converter, dmr);
}
 
Example 42
Project: cn1   File: ThreadInfoTest.java   Source Code and License 6 votes vote down vote up
public void test_from_scenario12() throws Exception {
    initialValues[8] = null;
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}
 
Example 43
Project: cn1   File: ThreadInfoTest.java   Source Code and License 6 votes vote down vote up
public void test_from_scenario16() throws Exception {
    initialValues[12] = null;
    ArrayType stackTraceArray = new ArrayType(1, stackTraceElementType);
    OpenType[] types = { SimpleType.LONG, SimpleType.STRING,
            SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
            SimpleType.LONG, SimpleType.LONG, SimpleType.LONG,
            SimpleType.LONG, SimpleType.STRING, SimpleType.LONG,
            SimpleType.STRING, stackTraceArray, SimpleType.STRING };
    CompositeType compositeType = getCompositeType(initialNames, types);
    CompositeData data = new CompositeDataSupport(compositeType,
            initialNames, initialValues);
    try {
        ThreadInfo.from(data);
        fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        // Expected
    }
}
 
Example 44
Project: wildfly-core   File: LegacyTypeConverterUnitTestCase.java   Source Code and License 6 votes vote down vote up
@Test
public void testJsonObjectInComplexValue() throws Exception {
    ModelNode description = createDescription(ModelType.OBJECT);
    ModelNode complexValueType = new ModelNode();
    complexValueType.get("value", DESCRIPTION).set("A  value");
    complexValueType.get("value", TYPE).set(ModelType.OBJECT);
    description.get(VALUE_TYPE).set(complexValueType);

    TypeConverter converter = getConverter(description);

    CompositeType type = assertCast(CompositeType.class, converter.getOpenType());
    Set<String> keys = type.keySet();
    Assert.assertEquals(1, keys.size());

    Assert.assertEquals(SimpleType.STRING, type.getType("value"));

    ModelNode node = new ModelNode();
    node.get("value", "long").set(1L);
    node.get("value", "string").set("test");

    CompositeData data = assertCast(CompositeData.class, converter.fromModelNode(node));
    Assert.assertEquals(type, data.getCompositeType());
    Assert.assertEquals(ModelNode.fromJSONString(node.toJSONString(false)), converter.toModelNode(data));

}
 
Example 45
Project: andes   File: AMQQueueMBean.java   Source Code and License 6 votes vote down vote up
/**
 * initialises the openmbean data types
 */
private static void init() throws OpenDataException
{
    _msgContentAttributeTypes[0] = SimpleType.LONG; // For message id
    _msgContentAttributeTypes[1] = SimpleType.STRING; // For MimeType
    _msgContentAttributeTypes[2] = SimpleType.STRING; // For Encoding
    _msgContentAttributeTypes[3] = new ArrayType(1, SimpleType.BYTE); // For message content
    _msgContentType = new CompositeType("Message Content", "AMQ Message Content",
                VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.toArray(new String[VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.size()]),
                VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.toArray(new String[VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES_DESC.size()]),
                _msgContentAttributeTypes);

    _msgAttributeTypes[0] = SimpleType.LONG; // For message id
    _msgAttributeTypes[1] = new ArrayType(1, SimpleType.STRING); // For header attributes
    _msgAttributeTypes[2] = SimpleType.LONG; // For size
    _msgAttributeTypes[3] = SimpleType.BOOLEAN; // For redelivered
    _msgAttributeTypes[4] = SimpleType.LONG; // For queue position

    _messageDataType = new CompositeType("Message", "AMQ Message", 
            VIEW_MSGS_COMPOSITE_ITEM_NAMES_DESC.toArray(new String[VIEW_MSGS_COMPOSITE_ITEM_NAMES_DESC.size()]),
            VIEW_MSGS_COMPOSITE_ITEM_NAMES_DESC.toArray(new String[VIEW_MSGS_COMPOSITE_ITEM_NAMES_DESC.size()]), _msgAttributeTypes);
    _messagelistDataType = new TabularType("Messages", "List of messages", _messageDataType,
                                            VIEW_MSGS_TABULAR_UNIQUE_INDEX.toArray(new String[VIEW_MSGS_TABULAR_UNIQUE_INDEX.size()]));
}
 
Example 46
Project: wildfly-core   File: ExpressionTypeConverterUnitTestCase.java   Source Code and License 6 votes vote down vote up
@Test
public void testUndefinedTypeConverter() {
    TypeConverter converter = getConverter(new ModelNode());
    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());

    ModelNode node = new ModelNode();
    // BES 2013/01/10 This uses BigInteger; I'm not sure why. But use a value > Long.MAX_VALUE
    // so the json parser won't convert it down to a long or int resulting in a different value
    // See AS7-4913
    // Likely BigInteger was used *because of* the problem discussed in AS7-4913
    node.get("abc").set(new BigInteger(String.valueOf(Long.MAX_VALUE) + "0"));
    node.get("def").set(false);
    node.protect();

    String json = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(node, ModelNode.fromJSONString(json));
    Assert.assertEquals(json, assertCast(String.class, converter.fromModelNode(node)));
    assertToArray(converter, json);
}
 
Example 47
Project: alfresco-core   File: JMXUtils.java   Source Code and License 5 votes vote down vote up
public static OpenType<?> getOpenType(Object o)
{
    if(o instanceof Long)
    {
        return SimpleType.LONG;
    }
    else if(o instanceof String)
    {
        return SimpleType.STRING;
    }
    else if(o instanceof Date)
    {
        return SimpleType.DATE;
    }
    else if(o instanceof Integer)
    {
        return SimpleType.INTEGER;
    }
    else if(o instanceof Boolean)
    {
        return SimpleType.BOOLEAN;
    }
    else if(o instanceof Double)
    {
        return SimpleType.DOUBLE;
    }
    else if(o instanceof Float)
    {
        return SimpleType.FLOAT;
    }
    else
    {
        throw new IllegalArgumentException();
    }
}
 
Example 48
Project: OpenJSharp   File: GcInfoCompositeData.java   Source Code and License 5 votes vote down vote up
static synchronized OpenType[] getBaseGcInfoItemTypes() {
    if (baseGcInfoItemTypes == null) {
        OpenType<?> memoryUsageOpenType = memoryUsageMapType.getOpenType();
        baseGcInfoItemTypes = new OpenType<?>[] {
            SimpleType.LONG,
            SimpleType.LONG,
            SimpleType.LONG,
            SimpleType.LONG,

            memoryUsageOpenType,
            memoryUsageOpenType,
        };
    }
    return baseGcInfoItemTypes;
}
 
Example 49
Project: ChronoBike   File: LogCenter.java   Source Code and License 5 votes vote down vote up
public CompositeType getStateType()
{
	CompositeTypeDesc compositeTypeDesc = new CompositeTypeDesc("LogCenterCompositeType", "LogCenterCompositeType Desc");
	compositeTypeDesc.addItem("Enable", "EnableDesc", SimpleType.BOOLEAN);
	compositeTypeDesc.addItem("Level", "LevelDesc", SimpleType.STRING);
	return compositeTypeDesc.generateCompositeType();
}
 
Example 50
Project: jdk8u-jdk   File: GcInfoCompositeData.java   Source Code and License 5 votes vote down vote up
static synchronized OpenType[] getBaseGcInfoItemTypes() {
    if (baseGcInfoItemTypes == null) {
        OpenType<?> memoryUsageOpenType = memoryUsageMapType.getOpenType();
        baseGcInfoItemTypes = new OpenType<?>[] {
            SimpleType.LONG,
            SimpleType.LONG,
            SimpleType.LONG,
            SimpleType.LONG,

            memoryUsageOpenType,
            memoryUsageOpenType,
        };
    }
    return baseGcInfoItemTypes;
}
 
Example 51
Project: jdk8u-jdk   File: MerlinMXBean.java   Source Code and License 5 votes vote down vote up
static ArrayType make(SimpleType baseType, boolean primitiveArray) {
    try {
        return new ArrayType(baseType, primitiveArray);
    } catch (OpenDataException e) {
        throw new Error(e);
    }
}
 
Example 52
Project: jdk8u-jdk   File: MXBeanTest.java   Source Code and License 5 votes vote down vote up
private static void testMXBean(MBeanServer mbs, ObjectName on)
        throws Exception {
    MBeanInfo mbi = mbs.getMBeanInfo(on);
    MBeanAttributeInfo[] attrs = mbi.getAttributes();
    int nattrs = attrs.length;
    if (mbi.getAttributes().length != 1)
        failure("wrong number of attributes: " + attrs);
    else {
        MBeanAttributeInfo mbai = attrs[0];
        if (mbai.getName().equals("Ints")
            && mbai.isReadable() && !mbai.isWritable()
            && mbai.getDescriptor().getFieldValue("openType")
                .equals(new ArrayType<int[]>(SimpleType.INTEGER, true))
            && attrs[0].getType().equals("[I"))
            success("MBeanAttributeInfo");
        else
            failure("MBeanAttributeInfo: " + mbai);
    }

    int[] ints = (int[]) mbs.getAttribute(on, "Ints");
    if (equal(ints, new int[] {1, 2, 3}, null))
        success("getAttribute");
    else
        failure("getAttribute: " + Arrays.toString(ints));

    ExplicitMXBean proxy =
        JMX.newMXBeanProxy(mbs, on, ExplicitMXBean.class);
    int[] pints = proxy.getInts();
    if (equal(pints, new int[] {1, 2, 3}, null))
        success("getAttribute through proxy");
    else
        failure("getAttribute through proxy: " + Arrays.toString(pints));
}
 
Example 53
Project: openjdk-jdk10   File: GcInfoCompositeData.java   Source Code and License 5 votes vote down vote up
static synchronized OpenType<?>[] getBaseGcInfoItemTypes() {
    if (baseGcInfoItemTypes == null) {
        OpenType<?> memoryUsageOpenType = memoryUsageMapType.getOpenType();
        baseGcInfoItemTypes = new OpenType<?>[] {
            SimpleType.LONG,
            SimpleType.LONG,
            SimpleType.LONG,
            SimpleType.LONG,

            memoryUsageOpenType,
            memoryUsageOpenType,
        };
    }
    return baseGcInfoItemTypes;
}
 
Example 54
Project: openjdk-jdk10   File: CompatibilityTest.java   Source Code and License 5 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {
    compositeTypeV6 = new CompositeType(
        StackTraceElement.class.getName(),
        "StackTraceElement",
        new String[]{
            "className", "methodName", "fileName", "nativeMethod", "lineNumber"
        },
        new String[]{
            "className", "methodName", "fileName", "nativeMethod", "lineNumber"
        },
        new OpenType[]{
            SimpleType.STRING,
            SimpleType.STRING,
            SimpleType.STRING,
            SimpleType.BOOLEAN,
            SimpleType.INTEGER
        }
    );

    itemsV6 = new HashMap<>();
    itemsV6.put("className", "MyClass");
    itemsV6.put("methodName", "myMethod");
    itemsV6.put("fileName", "MyClass.java");
    itemsV6.put("nativeMethod", false);
    itemsV6.put("lineNumber", 123);

    compositeDataV6 = new CompositeDataSupport(compositeTypeV6, itemsV6);
}
 
Example 55
Project: openjdk-jdk10   File: MerlinMXBean.java   Source Code and License 5 votes vote down vote up
static ArrayType make(SimpleType baseType, boolean primitiveArray) {
    try {
        return new ArrayType(baseType, primitiveArray);
    } catch (OpenDataException e) {
        throw new Error(e);
    }
}
 
Example 56
Project: openjdk-jdk10   File: MXBeanTest.java   Source Code and License 5 votes vote down vote up
private static void testMXBean(MBeanServer mbs, ObjectName on)
        throws Exception {
    MBeanInfo mbi = mbs.getMBeanInfo(on);
    MBeanAttributeInfo[] attrs = mbi.getAttributes();
    int nattrs = attrs.length;
    if (mbi.getAttributes().length != 1)
        failure("wrong number of attributes: " + attrs);
    else {
        MBeanAttributeInfo mbai = attrs[0];
        if (mbai.getName().equals("Ints")
            && mbai.isReadable() && !mbai.isWritable()
            && mbai.getDescriptor().getFieldValue("openType")
                .equals(new ArrayType<int[]>(SimpleType.INTEGER, true))
            && attrs[0].getType().equals("[I"))
            success("MBeanAttributeInfo");
        else
            failure("MBeanAttributeInfo: " + mbai);
    }

    int[] ints = (int[]) mbs.getAttribute(on, "Ints");
    if (equal(ints, new int[] {1, 2, 3}, null))
        success("getAttribute");
    else
        failure("getAttribute: " + Arrays.toString(ints));

    ExplicitMXBean proxy =
        JMX.newMXBeanProxy(mbs, on, ExplicitMXBean.class);
    int[] pints = proxy.getInts();
    if (equal(pints, new int[] {1, 2, 3}, null))
        success("getAttribute through proxy");
    else
        failure("getAttribute through proxy: " + Arrays.toString(pints));
}
 
Example 57
Project: hashsdn-controller   File: JavaAttribute.java   Source Code and License 5 votes vote down vote up
private OpenType<?> getEnumType(final TypeDefinition<?> baseType) {
    final String fullyQualifiedName = this.typeProviderWrapper.getType(this.node, getTypeDefinition()).getFullyQualifiedName();
    final String[] items = {"instance"};
    final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();

    try {
        return new CompositeType(fullyQualifiedName, description, items, items, new OpenType[]{SimpleType.STRING});
    } catch (final OpenDataException e) {
        throw new RuntimeException("Unable to create enum type" + fullyQualifiedName + " as open type", e);
    }
}
 
Example 58
Project: hashsdn-controller   File: JavaAttribute.java   Source Code and License 5 votes vote down vote up
public OpenType<?> getCompositeTypeForIdentity() {
    final String[] itemNames = new String[]{IdentityAttributeRef.QNAME_ATTR_NAME};
    final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
    final OpenType<?>[] itemTypes = new OpenType[]{SimpleType.STRING};

    try {
        return new CompositeType(getUpperCaseCammelCase(), description, itemNames, itemNames, itemTypes);
    } catch (final OpenDataException e) {
        throw new RuntimeException("Unable to create " + CompositeType.class + " with inner element of type "
                + itemTypes, e);
    }
}
 
Example 59
Project: hashsdn-controller   File: JavaAttribute.java   Source Code and License 5 votes vote down vote up
private OpenType<?> getArrayOpenTypeForSimpleType(final String innerTypeFullyQName, final SimpleType<?> innerSimpleType) {
    try {
        final ArrayType<Object> arrayType = isPrimitive(innerTypeFullyQName) ? new ArrayType<>(innerSimpleType, true)
                : new ArrayType<>(1, innerSimpleType);
        return arrayType;
    } catch (final OpenDataException e) {
        throw new RuntimeException("Unable to create " + ArrayType.class + " with inner element of type "
                + innerSimpleType, e);
    }
}
 
Example 60
Project: hashsdn-controller   File: SimpleTypeResolver.java   Source Code and License 5 votes vote down vote up
public static SimpleType<?> getSimpleType(final Type type) {
    final SimpleType<?> expectedSimpleType = JAVA_TYPE_TO_SIMPLE_TYPE.get(type
            .getFullyQualifiedName());
    Preconditions.checkState(expectedSimpleType != null,
            "Cannot find simple type for " + type.getFullyQualifiedName());
    return expectedSimpleType;
}