本文整理汇总了Java中org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException类的典型用法代码示例。如果您正苦于以下问题:Java AnalyticsException类的具体用法?Java AnalyticsException怎么用?Java AnalyticsException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnalyticsException类属于org.wso2.carbon.analytics.datasource.commons.exception包,在下文中一共展示了AnalyticsException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllEventsForDevice
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; //导入依赖的package包/类
private static EventRecords getAllEventsForDevice(String tableName, String query, List<SortByField> sortByFields
, int offset, int limit) throws AnalyticsException {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
EventRecords eventRecords = new EventRecords();
int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
if (eventCount == 0) {
eventRecords.setCount(0);
}
List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, offset, limit,
sortByFields);
List<String> recordIds = getRecordIds(resultEntries);
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
eventRecords.setCount(eventCount);
eventRecords.setList(AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response));
return eventRecords;
}
示例2: getLinesFromDASTable
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; //导入依赖的package包/类
public static JavaRDD<String> getLinesFromDASTable(String tableName, int tenantId, JavaSparkContext sparkContext)
throws AnalyticsTableNotAvailableException, AnalyticsException {
JavaRDD<String> lines;
String tableSchema = extractTableSchema(tableName, tenantId);
SQLContext sqlCtx = new SQLContext(sparkContext);
sqlCtx.sql("CREATE TEMPORARY TABLE ML_REF USING org.wso2.carbon.analytics.spark.core.sources.AnalyticsRelationProvider "
+ "OPTIONS ("
+ "tenantId \""
+ tenantId
+ "\", "
+ "tableName \""
+ tableName
+ "\", "
+ "schema \""
+ tableSchema + "\"" + ")");
DataFrame dataFrame = sqlCtx.sql("select * from ML_REF");
// Additional auto-generated column "_timestamp" needs to be dropped because it is not in the schema.
JavaRDD<Row> rows = dataFrame.drop("_timestamp").javaRDD();
lines = rows.map(new RowsToLines.Builder().separator(CSVFormat.RFC4180.getDelimiter() + "").build());
return lines;
}
示例3: extractTableSchema
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; //导入依赖的package包/类
public static String extractTableSchema(String path, int tenantId) throws AnalyticsTableNotAvailableException,
AnalyticsException {
if (path == null) {
return null;
}
AnalyticsDataAPI analyticsDataApi = (AnalyticsDataAPI) PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getOSGiService(AnalyticsDataAPI.class, null);
// table schema will be something like; <col1_name> <col1_type>,<col2_name> <col2_type>
StringBuilder sb = new StringBuilder();
AnalyticsSchema analyticsSchema = analyticsDataApi.getTableSchema(tenantId, path);
Map<String, ColumnDefinition> columnsMap = analyticsSchema.getColumns();
for (Iterator<Map.Entry<String, ColumnDefinition>> iterator = columnsMap.entrySet().iterator(); iterator
.hasNext();) {
Map.Entry<String, ColumnDefinition> column = iterator.next();
sb.append(column.getKey() + " " + column.getValue().getType().name() + ",");
}
return sb.substring(0, sb.length() - 1);
}
示例4: extractHeaderLine
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; //导入依赖的package包/类
public static String extractHeaderLine(String path, int tenantId) throws AnalyticsTableNotAvailableException,
AnalyticsException {
if (path == null) {
return null;
}
AnalyticsDataAPI analyticsDataApi = (AnalyticsDataAPI) PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getOSGiService(AnalyticsDataAPI.class, null);
// header line will be something like; <col1_name>,<col2_name>
StringBuilder sb = new StringBuilder();
AnalyticsSchema analyticsSchema = analyticsDataApi.getTableSchema(tenantId, path);
Map<String, ColumnDefinition> columnsMap = analyticsSchema.getColumns();
for (String columnName : columnsMap.keySet()) {
sb.append(columnName + ",");
}
return sb.substring(0, sb.length() - 1);
}
示例5: getAllEventsForDevice
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; //导入依赖的package包/类
public static List<SensorRecord> getAllEventsForDevice(String tableName, String query,
List<SortByField> sortByFields) throws AnalyticsException {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
// limiting the data read from the server
int start = 0;
int dataCount = 100;
if (eventCount == 0) {
return null;
} else if (eventCount >= dataCount){
start = eventCount - dataCount;
}
List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, start, eventCount,
sortByFields);
List<String> recordIds = getRecordIds(resultEntries);
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
Map<String, SensorRecord> sensorDatas = createSensorData(AnalyticsDataAPIUtil.listRecords(
analyticsDataAPI, response));
List<SensorRecord> sortedSensorData = getSortedSensorData(sensorDatas, resultEntries);
return sortedSensorData;
}
示例6: getAllEventsForDevice
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; //导入依赖的package包/类
/**
* Get sensor data for a device.
*
* @param tableName table name of the data source
* @param query query for the table
* @param sortByFields list of fields to sort the data by
* @return List of SensorRecords that is sorted by the fields provided
* @throws AnalyticsException
*/
public static List<SensorRecord> getAllEventsForDevice(String tableName, String query,
List<SortByField> sortByFields) throws AnalyticsException {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
if (eventCount == 0) {
return null;
}
List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, 0, eventCount,
sortByFields);
List<String> recordIds = getRecordIds(resultEntries);
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
Map<String, SensorRecord> sensorDatas = createSensorData(AnalyticsDataAPIUtil.listRecords(
analyticsDataAPI, response));
List<SensorRecord> sortedSensorData = getSortedSensorData(sensorDatas, resultEntries);
return sortedSensorData;
}
示例7: getAllEventsForDevice
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; //导入依赖的package包/类
public static List<SensorRecord> getAllEventsForDevice(String tableName, String query,
List<SortByField> sortByFields) throws AnalyticsException {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
if (eventCount == 0) {
return null;
}
List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, 0, eventCount,
sortByFields);
List<String> recordIds = getRecordIds(resultEntries);
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
Map<String, SensorRecord> sensorDatas = createSensorData(AnalyticsDataServiceUtils.listRecords(
analyticsDataAPI, response));
List<SensorRecord> sortedSensorData = getSortedSensorData(sensorDatas, resultEntries);
return sortedSensorData;
}
示例8: getEventBeans
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; //导入依赖的package包/类
private List<Event> getEventBeans(AnalyticsDataAPI analyticsDataAPI, int tenantId, String tableName,
List<String> columns,
List<SearchResultEntry> searchResults) throws AnalyticsException {
List<String> ids = getIds(searchResults);
List<String> requiredColumns = (columns == null || columns.isEmpty()) ? null : columns;
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, requiredColumns, ids);
List<Record> records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response);
Map<String, Event> eventBeanMap = getEventBeanKeyedWithIds(records);
return getSortedEventBeans(eventBeanMap, searchResults);
}
示例9: process
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; //导入依赖的package包/类
public void process() throws MLDataProcessingException {
MLDataset dataset = getDataset();
setTargetPath(dataset.getSourcePath());
try {
setFirstLine(MLUtils.extractHeaderLine(dataset.getSourcePath(), dataset.getTenantId()));
} catch (AnalyticsException e) {
throw new MLDataProcessingException(e.getMessage(), e);
}
}