Package org.opennms.netmgt.newts.support
Class NewtsUtils
- java.lang.Object
-
- org.opennms.netmgt.newts.support.NewtsUtils
-
public abstract class NewtsUtils extends Object
Utility functions and constants.- Author:
- jwhite
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_HOSTNAMEstatic StringDEFAULT_KEYSPACEstatic StringDEFAULT_PORTstatic StringDEFAULT_TTLstatic booleanDISABLE_INDEXINGstatic StringHOSTNAME_PROPERTYstatic org.opennms.newts.cassandra.search.CassandraIndexingOptionsINDEXING_OPTIONSstatic StringKEYSPACE_PROPERTYstatic intMAX_BATCH_SIZEstatic StringPORT_PROPERTYstatic intTTLstatic StringTTL_PROPERTY
-
Constructor Summary
Constructors Constructor Description NewtsUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddIndicesToAttributes(ResourcePath path, Map<String,String> attributes)Extends the attribute map with indices used by theNewtsResourceStorageDao.static org.opennms.newts.api.SamplecreateSampleForIndexingStrings(org.opennms.newts.api.Context context, org.opennms.newts.api.Resource resource)Creates a sample used to index string attributes.static org.opennms.newts.api.search.QueryfindResourcesWithMetricsAtDepth(ResourcePath path, int depth)Constructs a query used to find all of the resources that have one or more metrics at the given depth bellow the path.static StringtoMetricName(String resourceId)Extracts the metric name from the resource id.static StringtoResourceId(ResourcePath path)Converts aResourcePathto a Newts resource id.static ResourcePathtoResourcePath(String resourceId)Converts a Newts resource id to aResourcePath.
-
-
-
Field Detail
-
DISABLE_INDEXING
public static final boolean DISABLE_INDEXING
-
MAX_BATCH_SIZE
public static final int MAX_BATCH_SIZE
-
TTL
public static final int TTL
-
HOSTNAME_PROPERTY
public static final String HOSTNAME_PROPERTY
- See Also:
- Constant Field Values
-
KEYSPACE_PROPERTY
public static final String KEYSPACE_PROPERTY
- See Also:
- Constant Field Values
-
PORT_PROPERTY
public static final String PORT_PROPERTY
- See Also:
- Constant Field Values
-
TTL_PROPERTY
public static final String TTL_PROPERTY
- See Also:
- Constant Field Values
-
DEFAULT_HOSTNAME
public static final String DEFAULT_HOSTNAME
- See Also:
- Constant Field Values
-
DEFAULT_KEYSPACE
public static final String DEFAULT_KEYSPACE
- See Also:
- Constant Field Values
-
DEFAULT_PORT
public static final String DEFAULT_PORT
- See Also:
- Constant Field Values
-
DEFAULT_TTL
public static final String DEFAULT_TTL
- See Also:
- Constant Field Values
-
INDEXING_OPTIONS
public static final org.opennms.newts.cassandra.search.CassandraIndexingOptions INDEXING_OPTIONS
-
-
Method Detail
-
addIndicesToAttributes
public static void addIndicesToAttributes(ResourcePath path, Map<String,String> attributes)
Extends the attribute map with indices used by theNewtsResourceStorageDao. A resource path of the form [a, b, c, d] will be indexed with:- _idx1: (a, 4)
- _idx2: (a:b, 4)
- _idx3: (a:b:c, 4)
-
findResourcesWithMetricsAtDepth
public static org.opennms.newts.api.search.Query findResourcesWithMetricsAtDepth(ResourcePath path, int depth)
Constructs a query used to find all of the resources that have one or more metrics at the given depth bellow the path. Requires resources to have been indexed usingaddIndicesToAttributes(org.opennms.netmgt.model.ResourcePath, java.util.Map<java.lang.String, java.lang.String>).
-
toResourceId
public static String toResourceId(ResourcePath path)
Converts aResourcePathto a Newts resource id.- Parameters:
path- path to convert- Returns:
- Newts resource id
-
toResourcePath
public static ResourcePath toResourcePath(String resourceId)
Converts a Newts resource id to aResourcePath.- Parameters:
resourceId- Newts resource id- Returns:
- path
-
toMetricName
public static String toMetricName(String resourceId)
Extracts the metric name from the resource id.- Parameters:
resourceId- Newts resource id- Returns:
- metric name
-
createSampleForIndexingStrings
public static org.opennms.newts.api.Sample createSampleForIndexingStrings(org.opennms.newts.api.Context context, org.opennms.newts.api.Resource resource)Creates a sample used to index string attributes. These should only be index and not be persisted.
-
-