UpgradeCatalog222 extends AbstractUpgradeCatalog { protected void updateCorruptedReplicaWidget() throws SQLException { String widgetValues = String.format("[{\"name\": \"%s\", \"value\": \"%s\"}]", WIDGET_CORRUPT_REPLICAS, WIDGET_VALUES_VALUE); String updateStatement = "UPDATE %s SET %s='%s', %s='%s', %s='%s' WHERE %s='%s'"; LOG.info("Update widget definition for HDFS corrupted blocks metric"); dbAccessor.executeUpdate(String.format(updateStatement, WIDGET_TABLE, WIDGET_NAME, WIDGET_CORRUPT_REPLICAS, WIDGET_DESCRIPTION, WIDGET_CORRUPT_REPLICAS_DESCRIPTION, WIDGET_VALUES, widgetValues, WIDGET_NAME, WIDGET_CORRUPT_BLOCKS )); } @Inject  UpgradeCatalog222(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); static final String PRECISION_TABLE_TTL_PROPERTY; static final String CLUSTER_SECOND_TABLE_TTL_PROPERTY; static final String CLUSTER_MINUTE_TABLE_TTL_PROPERTY; static final String AMS_WEBAPP_ADDRESS_PROPERTY; static final String HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD_PROPERTY; static final String HBASE_RPC_TIMEOUT_PROPERTY; static final String PHOENIX_QUERY_TIMEOUT_PROPERTY; static final String PHOENIX_QUERY_KEEPALIVE_PROPERTY; static final String TIMELINE_METRICS_CLUSTER_AGGREGATOR_INTERPOLATION_ENABLED; static final String TIMELINE_METRICS_SINK_COLLECTION_PERIOD; static final String AMS_SERVICE_NAME; static final String AMS_COLLECTOR_COMPONENT_NAME; final static String HBASE_SITE_HBASE_COPROCESSOR_MASTER_CLASSES; final static String HBASE_SITE_HBASE_COPROCESSOR_REGION_CLASSES; final static String HBASE_SITE_HBASE_COPROCESSOR_REGIONSERVER_CLASSES; }
@Test public void testUpdateCorruptedReplicaWidget() throws SQLException{ final DBAccessor dbAccessor = createStrictMock(DBAccessor.class); Module module = new Module() { @Override public void configure(Binder binder) { binder.bind(DBAccessor.class).toInstance(dbAccessor); binder.bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class)); binder.bind(EntityManager.class).toInstance(entityManager); } }; Injector injector = Guice.createInjector(module); String expectedWidgetUpdate = "UPDATE widget SET widget_name='%s', description='%s', " + "widget_values='[{\"name\": \"%s\", \"value\": \"%s\"}]' WHERE widget_name='%s'"; Capture<String> capturedStatements = Capture.newInstance(CaptureType.ALL); expect(dbAccessor.executeUpdate(capture(capturedStatements))).andReturn(1); UpgradeCatalog222 upgradeCatalog222 = injector.getInstance(UpgradeCatalog222.class); replay(dbAccessor); upgradeCatalog222.updateCorruptedReplicaWidget(); List<String> statements = capturedStatements.getValues(); assertTrue(statements.contains(String.format(expectedWidgetUpdate, UpgradeCatalog222.WIDGET_CORRUPT_REPLICAS, UpgradeCatalog222.WIDGET_CORRUPT_REPLICAS_DESCRIPTION, UpgradeCatalog222.WIDGET_CORRUPT_REPLICAS, UpgradeCatalog222.WIDGET_VALUES_VALUE, UpgradeCatalog222.WIDGET_CORRUPT_BLOCKS))); }