Search in sources :

Example 1 with DataPoint

use of com.emc.storageos.db.client.model.TimeSeriesSerializer.DataPoint in project coprhd-controller by CoprHD.

the class DummyDBClient method queryTimeSeries.

@Override
public <T extends DataPoint> void queryTimeSeries(Class<? extends TimeSeries> tsType, DateTime timeBucket, TimeBucket bucket, TimeSeriesQueryResult<T> callback, ExecutorService workerThreads) throws DatabaseException {
    if (timeBucket != null) {
        MicrosecondsClock clock = new MicrosecondsClock();
        UUID uuid = TimeUUIDUtils.getTimeUUID(clock);
        // For timeBucket 2012-01-04T00:00 we return 10 events
        if (timeBucket.toString().contains("2012-01-01T00:00")) {
            try {
                for (int i = 0; i < 10; i++) {
                    Stat st = new Stat();
                    st.setProject(new URI("http://project" + i));
                    st.setTenant(new URI("http://t." + i));
                    st.setUser(new URI("http://u." + i));
                    st.setVirtualPool(new URI("http://vpool.gold" + i));
                    callback.data((T) st, TimeUUIDUtils.getTimeFromUUID(uuid));
                }
            } catch (URISyntaxException e) {
                _logger.error(e.getMessage(), e);
            }
            callback.done();
        } else if (timeBucket.toString().contains("2012-01-02T00:00")) {
            throw DatabaseException.retryables.dummyClientFailed();
        } else if (timeBucket.toString().contains("2012-01-03T00:00")) {
            callback.error(null);
        } else if (timeBucket.toString().contains("2012-01-04T00:00")) {
            try {
                // TODO Auto-generated method stub
                for (int i = 0; i < 10; i++) {
                    Event evt = new Event();
                    evt.setProjectId(new URI("http://project" + i));
                    evt.setEventId(String.valueOf(i));
                    evt.setTenantId(new URI("http://t." + i));
                    evt.setUserId(new URI("http://u." + i));
                    evt.setVirtualPool(new URI("http://vpool.gold" + i));
                    callback.data((T) evt, TimeUUIDUtils.getTimeFromUUID(uuid));
                }
            } catch (URISyntaxException e) {
                _logger.error(e.getMessage(), e);
            }
            callback.done();
        } else if (timeBucket.toString().contains("2012-01-05T00:00")) {
            try {
                throw new MarshallingExcetion("marshalling Exception", null);
            } catch (MarshallingExcetion e) {
                _logger.error(e.getMessage(), e);
            }
        } else if (timeBucket.toString().contains("2012-01-06T00:00")) {
            callback.error(null);
        } else if (timeBucket.toString().contains("2012-01-07T00:00")) {
            try {
                // TODO Auto-generated method stub
                for (int i = 0; i < 10; i++) {
                    AuditLog log = new AuditLog();
                    log.setProductId("productId." + i);
                    log.setTenantId(new URI("http://tenant." + i));
                    log.setUserId(new URI("http://user." + i));
                    log.setServiceType("serviceType" + i);
                    log.setAuditType("auditType" + i);
                    log.setDescription("description" + i);
                    callback.data((T) log, TimeUUIDUtils.getTimeFromUUID(uuid));
                }
            } catch (URISyntaxException e) {
                _logger.error(e.getMessage(), e);
            }
            callback.done();
        } else if (timeBucket.toString().contains("2012-01-08T00:00")) {
            try {
                throw new MarshallingExcetion("marshalling Exception", null);
            } catch (MarshallingExcetion e) {
                _logger.error(e.getMessage(), e);
            }
        }
    }
}
Also used : MarshallingExcetion(com.emc.storageos.api.service.impl.resource.utils.MarshallingExcetion) Stat(com.emc.storageos.db.client.model.Stat) MicrosecondsClock(com.netflix.astyanax.clock.MicrosecondsClock) Event(com.emc.storageos.db.client.model.Event) URISyntaxException(java.net.URISyntaxException) UUID(java.util.UUID) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Constraint(com.emc.storageos.db.client.constraint.Constraint) DataPoint(com.emc.storageos.db.client.model.TimeSeriesSerializer.DataPoint) AuditLog(com.emc.storageos.db.client.model.AuditLog)

Aggregations

MarshallingExcetion (com.emc.storageos.api.service.impl.resource.utils.MarshallingExcetion)1 Constraint (com.emc.storageos.db.client.constraint.Constraint)1 AuditLog (com.emc.storageos.db.client.model.AuditLog)1 Event (com.emc.storageos.db.client.model.Event)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 Stat (com.emc.storageos.db.client.model.Stat)1 DataPoint (com.emc.storageos.db.client.model.TimeSeriesSerializer.DataPoint)1 MicrosecondsClock (com.netflix.astyanax.clock.MicrosecondsClock)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 UUID (java.util.UUID)1