use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class DataFileStoreDataManager method reload.
@Override
public void reload() throws IndyDataException {
// NOTE: Call to super for this, because the local implementation DELETES THE DB DIR!!!
super.clear(new ChangeSummary(ChangeSummary.SYSTEM_USER, "Reloading from storage"));
readDefinitions();
}
use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class DataFileTCKFixtureProvider method before.
@Override
protected void before() throws Throwable {
super.before();
configDir = newFolder("db");
final IndyObjectMapper serializer = new IndyObjectMapper(true);
dataManager = new TestFlatFileDataManager(new DataFileConfiguration().withDataBasedir(configDir), serializer);
dataManager.install();
dataManager.clear(new ChangeSummary(ChangeSummary.SYSTEM_USER, "Setting up test"));
}
use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class StoreEnablementManager method onStoreError.
// public void onStoreUpdate( @Observes ArtifactStorePostUpdateEvent event )
// {
// for ( ArtifactStore store : event )
// {
// if ( store.isDisabled() )
// {
// String toStr = store.getMetadata( DISABLE_TIMEOUT );
// if ( isNotEmpty( toStr ) )
// {
// int timeout = Integer.parseInt( toStr );
// try
// {
// setReEnablementTimeout( store.getKey(), timeout );
// }
// catch ( IndySchedulerException e )
// {
// Logger logger = LoggerFactory.getLogger( getClass() );
// logger.error( String.format( "Failed to schedule re-enablement of %s.", store.getKey() ), e );
// }
// }
// }
//// else
//// {
//// try
//// {
//// cancelReEnablementTimeout( store.getKey() );
//// }
//// catch ( IndySchedulerException e )
//// {
//// Logger logger = LoggerFactory.getLogger( getClass() );
//// logger.error( String.format( "Failed to delete re-enablement job for %s.", store.getKey() ), e );
//// }
//// }
// }
// }
public void onStoreError(@Observes IndyStoreErrorEvent evt) {
Logger logger = LoggerFactory.getLogger(getClass());
StoreKey key = evt.getStoreKey();
Throwable error = evt.getError();
try {
ArtifactStore store = storeDataManager.getArtifactStore(key);
if (store.getDisableTimeout() <= TIMEOUT_NEVER_DISABLE) {
logger.debug("Disable-timeout set to {}, will never disable the repo", store.getDisableTimeout());
store.setDisabled(false);
} else {
store.setDisabled(true);
}
final ChangeSummary changeSummary = new ChangeSummary(ChangeSummary.SYSTEM_USER, String.format("Disabling %s due to error: %s\n\nStack Trace:\n %s", key, error, StringUtils.join(error.getStackTrace(), "\n ")));
storeDataManager.storeArtifactStore(store, changeSummary, false, true, new EventMetadata());
logger.warn("{} has been disabled due to store-level error: {}\n Will re-enable in {} seconds.", key, error, config.getStoreDisableTimeoutSeconds());
// TODO: How is it this doesn't duplicate the event handler method onStoreUpdate()...we're updating the store just above here.
setReEnablementTimeout(key);
} catch (IndyDataException e) {
logger.error(String.format("Failed to disable %s on error: %s", key, error), e);
} catch (IndySchedulerException e) {
logger.error(String.format("Failed to schedule re-enablement of %s for retry.", key), e);
}
}
use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class StoreEnablementManager method onDisableTimeout.
public void onDisableTimeout(@Observes SchedulerEvent evt) {
Logger logger = LoggerFactory.getLogger(getClass());
logger.debug("Checking for store-reenable event in: {} (trigger? {} Disable-Timeout? {})", evt, evt instanceof SchedulerTriggerEvent, DISABLE_TIMEOUT.equals(evt.getJobType()));
if ((evt instanceof SchedulerTriggerEvent) && DISABLE_TIMEOUT.equals(evt.getJobType())) {
String keystr = evt.getPayload();
StoreKey key = null;
try {
key = objectMapper.readValue(keystr, StoreKey.class);
} catch (IOException e) {
logger.warn("Failed to read StoreKey from JSON string: '{}' in event payload.", keystr);
}
logger.debug("Read key: {} from JSON string: '{}' in event payload.", key, keystr);
if (key != null) {
try {
ArtifactStore store = storeDataManager.getArtifactStore(key);
if (store.isDisabled()) {
store.setDisabled(false);
storeDataManager.storeArtifactStore(store, new ChangeSummary(ChangeSummary.SYSTEM_USER, "Re-enabling " + key), false, true, new EventMetadata());
cancelReEnablementTimeout(key);
}
} catch (IndyDataException e) {
logger.error(String.format("Failed to re-enable %s", key), e);
} catch (IndySchedulerException e) {
logger.error(String.format("Failed to delete re-enablement job for %s.", key), e);
}
}
}
}
use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class AdminController method store.
public boolean store(final ArtifactStore store, final String user, final boolean skipExisting) throws IndyWorkflowException {
try {
String changelog = store.getMetadata(ArtifactStore.METADATA_CHANGELOG);
if (changelog == null) {
changelog = "Changelog not provided";
}
final ChangeSummary summary = new ChangeSummary(user, changelog);
logger.info("Persisting artifact store: {} using: {}", store, storeManager);
return storeManager.storeArtifactStore(store, summary, skipExisting, true, new EventMetadata());
} catch (final IndyDataException e) {
throw new IndyWorkflowException(ApplicationStatus.SERVER_ERROR.code(), "Failed to store: {}. Reason: {}", e, store.getKey(), e.getMessage());
}
}
Aggregations