use of org.graylog2.plugin.database.ValidationException in project graylog2-server by Graylog2.
the class V20161116172200_CreateDefaultStreamMigration method createDefaultStream.
private void createDefaultStream() {
final IndexSet indexSet = indexSetRegistry.getDefault();
final ObjectId id = new ObjectId(Stream.DEFAULT_STREAM_ID);
final Map<String, Object> fields = ImmutableMap.<String, Object>builder().put(StreamImpl.FIELD_TITLE, "All messages").put(StreamImpl.FIELD_DESCRIPTION, "Stream containing all messages").put(StreamImpl.FIELD_DISABLED, false).put(StreamImpl.FIELD_CREATED_AT, DateTime.now(DateTimeZone.UTC)).put(StreamImpl.FIELD_CREATOR_USER_ID, "local:admin").put(StreamImpl.FIELD_MATCHING_TYPE, StreamImpl.MatchingType.DEFAULT.name()).put(StreamImpl.FIELD_REMOVE_MATCHES_FROM_DEFAULT_STREAM, false).put(StreamImpl.FIELD_DEFAULT_STREAM, true).put(StreamImpl.FIELD_INDEX_SET_ID, indexSet.getConfig().id()).build();
final Stream stream = new StreamImpl(id, fields, Collections.emptyList(), Collections.emptySet(), indexSet);
try {
streamService.save(stream);
LOG.info("Successfully created default stream: {}", stream.getTitle());
} catch (ValidationException e) {
LOG.error("Couldn't create default stream! This is a bug!");
}
clusterEventBus.post(StreamsChangedEvent.create(stream.getId()));
}
use of org.graylog2.plugin.database.ValidationException in project graylog2-server by Graylog2.
the class V20161125142400_EmailAlarmCallbackMigration method migrateStream.
private Optional<String> migrateStream(Stream stream) {
final Map<String, Object> defaultConfig = this.getDefaultEmailAlarmCallbackConfig();
LOG.debug("Creating email alarm callback for stream <" + stream.getId() + ">");
final AlarmCallbackConfiguration alarmCallbackConfiguration = alarmCallbackService.create(stream.getId(), CreateAlarmCallbackRequest.create(EmailAlarmCallback.class.getCanonicalName(), "Email Alert Notification", defaultConfig), localAdminUser.getId());
try {
final String callbackId = this.alarmCallbackService.save(alarmCallbackConfiguration);
LOG.debug("Successfully created email alarm callback <" + callbackId + "> for stream <" + stream.getId() + ">.");
return Optional.of(callbackId);
} catch (ValidationException e) {
LOG.error("Unable to create email alarm callback for stream <" + stream.getId() + ">: ", e);
}
return Optional.empty();
}
use of org.graylog2.plugin.database.ValidationException in project graylog2-server by Graylog2.
the class LdapGroupMappingMigration method doRun.
@Override
public void doRun() {
final LdapSettings ldapSettings = ldapSettingsService.load();
if (ldapSettings != null) {
ldapSettings.setGroupMapping(ldapSettings.getGroupMapping());
try {
ldapSettingsService.save(ldapSettings);
clusterConfigService.write(LdapGroupMappingMigrationState.create(true));
log.info("Migrated LDAP group mapping format");
} catch (ValidationException e) {
log.error("Unable to save migrated LDAP settings!", e);
}
}
}
use of org.graylog2.plugin.database.ValidationException in project graylog2-server by Graylog2.
the class LdapUserAuthenticator method syncFromLdapEntry.
@Nullable
@VisibleForTesting
User syncFromLdapEntry(LdapEntry userEntry, LdapSettings ldapSettings, String username) {
User user = userService.load(username);
// create new user object if necessary
if (user == null) {
user = userService.create();
}
// update user attributes from ldap entry
updateFromLdap(user, userEntry, ldapSettings, username);
try {
userService.save(user);
} catch (ValidationException e) {
LOG.error("Cannot save user.", e);
return null;
}
return user;
}
use of org.graylog2.plugin.database.ValidationException in project graylog2-server by Graylog2.
the class StreamFaultManager method registerFailure.
public void registerFailure(final Stream stream) {
final AtomicInteger faultCount = getFaultCount(stream);
final int streamFaultCount = faultCount.incrementAndGet();
streamMetrics.markStreamRuleTimeout(stream.getId());
if (maxFaultCount > 0 && streamFaultCount >= maxFaultCount) {
try {
streamService.pause(stream);
faultCount.set(0);
streamMetrics.markStreamFaultsExceeded(stream.getId());
LOG.error("Processing of stream <{}> failed to return within {}ms for more than {} times. Disabling stream.", stream.getId(), streamProcessingTimeout, maxFaultCount);
triggerNotification(stream, streamFaultCount);
} catch (ValidationException ex) {
LOG.error("Unable to pause stream: {}", ex);
}
} else {
LOG.warn("Processing of stream <{}> failed to return within {}ms.", stream.getId(), streamProcessingTimeout);
}
}
Aggregations