Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Sep 7, 2018
2 parents 4af350c + e92269a commit 7dcb7c9
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 55 deletions.
4 changes: 2 additions & 2 deletions gui/admin-gui/src/main/resources/logback-console.xml
Expand Up @@ -20,9 +20,9 @@
<define name="consoleTimezone" class="com.evolveum.midpoint.common.LogbackPropertyDefinerForConsoleTimezone" />

<appender name="DEFAULT_CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<encoder>
<pattern>${consolePrefix}%date{ISO8601, ${consoleTimezone}} [%X{subsystem}] [%thread] %level \(%logger\): %msg%n</pattern>
</layout>
</encoder>
</appender>

</included>
27 changes: 13 additions & 14 deletions gui/admin-gui/src/main/resources/logback.xml
Expand Up @@ -20,40 +20,39 @@
<include resource="logback-console.xml" />

<appender name="MIDPOINT_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--See http://logback.qos.ch/manual/appenders.html#RollingFileAppender-->
<!--and http://logback.qos.ch/manual/appenders.html#TimeBasedRollingPolicy-->
<!--for further documentation-->
<!-- See http://logback.qos.ch/manual/appenders.html#RollingFileAppender -->
<!-- and http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy -->
<!-- for further documentation -->
<Append>true</Append>
<File>${midpoint.home}/log/midpoint.log</File>
<encoder>
<pattern>%date [%X{subsystem}] [%thread] %level \(%logger\): %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${midpoint.home}/log/midpoint-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxFileSize>100MB</maxFileSize>
<maxHistory>10</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
</appender>

<!-- Appender for profiling purposes -->
<appender name="MIDPOINT_PROFILE_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--See http://logback.qos.ch/manual/appenders.html#RollingFileAppender-->
<!--and http://logback.qos.ch/manual/appenders.html#TimeBasedRollingPolicy-->
<!--for further documentation-->
<!-- See http://logback.qos.ch/manual/appenders.html#RollingFileAppender -->
<!-- and http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedRollingPolicy -->
<!-- for further documentation -->
<Append>true</Append>
<File>${midpoint.home}/log/midpoint-profile.log</File>
<encoder>
<pattern>%date %level: %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${midpoint.home}/log/midpoint-profile-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxFileSize>100MB</maxFileSize>
<maxHistory>10</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
</appender>
<!-- Appender for profiling purposes -->
Expand Down
Expand Up @@ -296,7 +296,7 @@ private static void prepareFileAppenderConfiguration(StringBuilder sb, FileAppen

if (isRolling) {
//rolling policy
sb.append("\t\t<rollingPolicy class=\"ch.qos.logback.core.rolling.TimeBasedRollingPolicy\">\n");
sb.append("\t\t<rollingPolicy class=\"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy\">\n");
sb.append("\t\t\t<fileNamePattern>");
sb.append(filePattern);
sb.append("</fileNamePattern>\n");
Expand All @@ -305,16 +305,12 @@ private static void prepareFileAppenderConfiguration(StringBuilder sb, FileAppen
sb.append(appender.getMaxHistory());
sb.append("</maxHistory>\n");
}
sb.append("\t\t\t<cleanHistoryOnStart>true</cleanHistoryOnStart>");
sb.append("\t\t\t<cleanHistoryOnStart>true</cleanHistoryOnStart>\n");

// file triggering
// if max size is defined
if (!StringUtils.isEmpty(appender.getMaxFileSize())) {
sb.append("\t\t\t<timeBasedFileNamingAndTriggeringPolicy class=\"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP\">\n");
sb.append("\t\t\t\t<maxFileSize>");
sb.append("\t\t\t<maxFileSize>");
sb.append(appender.getMaxFileSize());
sb.append("</maxFileSize>\n");
sb.append("\t\t\t</timeBasedFileNamingAndTriggeringPolicy>\n");
}
sb.append("\t\t</rollingPolicy>\n");
}
Expand Down
Expand Up @@ -17,27 +17,24 @@

/**
* Dispatcher of change notifications.
*
*
* Instances that implement this interface relay notification from the source of the change notification to the
* destinations. The destinations are chosen dynamically, using a publish-subscribe mechanism.
*
*
* This interface also includes ResourceObjectChangeListener. By invoking the notifyChange(..) operation of this
* interface the change will be relayed to all registered listeners.
*
*
* @author Katka Valalikova
* @author Radovan Semancik
*
*/
public interface ChangeNotificationDispatcher extends ResourceObjectChangeListener, ResourceOperationListener, ResourceEventListener {

public void registerNotificationListener(ResourceObjectChangeListener listener);
public void registerNotificationListener(ResourceOperationListener listener);
public void registerNotificationListener(ResourceEventListener listener);

public void unregisterNotificationListener(ResourceObjectChangeListener listener);
public void unregisterNotificationListener(ResourceOperationListener listener);
public void unregisterNotificationListener(ResourceEventListener listener);




void registerNotificationListener(ResourceObjectChangeListener listener);
void registerNotificationListener(ResourceOperationListener listener);
void registerNotificationListener(ResourceEventListener listener);

void unregisterNotificationListener(ResourceObjectChangeListener listener);
void unregisterNotificationListener(ResourceOperationListener listener);
void unregisterNotificationListener(ResourceEventListener listener);
}
Expand Up @@ -69,6 +69,8 @@ public void setFilterProtectedObjects(boolean filterProtectedObjects) {
*/
@Override
public synchronized void registerNotificationListener(ResourceObjectChangeListener listener) {
Validate.notNull(listener);

if (changeListeners.contains(listener)) {
LOGGER.warn(
"Resource object change listener '{}' is already registered. Subsequent registration is ignored",
Expand All @@ -84,6 +86,8 @@ public synchronized void registerNotificationListener(ResourceObjectChangeListen
*/
@Override
public synchronized void registerNotificationListener(ResourceOperationListener listener) {
Validate.notNull(listener);

if (operationListeners.contains(listener)) {
LOGGER.warn(
"Resource operation listener '{}' is already registered. Subsequent registration is ignored",
Expand All @@ -95,6 +99,8 @@ public synchronized void registerNotificationListener(ResourceOperationListener
}
@Override
public synchronized void registerNotificationListener(ResourceEventListener listener) {
Validate.notNull(listener);

if (eventListeners.contains(listener)) {
LOGGER.warn(
"Resource event listener '{}' is already registered. Subsequent registration is ignored",
Expand Down Expand Up @@ -147,7 +153,8 @@ public void notifyChange(ResourceObjectShadowChangeDescription change, Task task
} catch (RuntimeException e) {
LOGGER.error("Exception {} thrown by object change listener {}: {}", e.getClass(), listener.getName(),
e.getMessage(), e);
parentResult.createSubresult(CLASS_NAME_WITH_DOT + "notifyChange").recordWarning("Change listener has thrown unexpected exception", e);
parentResult.createSubresult(CLASS_NAME_WITH_DOT + "notifyChange")
.recordWarning("Change listener has thrown unexpected exception", e);
throw e;
}
}
Expand All @@ -170,15 +177,16 @@ public void notifyFailure(ResourceOperationDescription failureDescription,

failureDescription.checkConsistence();

if ((null != changeListeners) && (!changeListeners.isEmpty())) {
if ((null != operationListeners) && (!operationListeners.isEmpty())) {
for (ResourceOperationListener listener : new ArrayList<>(operationListeners)) { // sometimes there is registration/deregistration from within
//LOGGER.trace("Listener: {}", listener.getClass().getSimpleName());
try {
listener.notifyFailure(failureDescription, task, parentResult);
} catch (RuntimeException e) {
LOGGER.error("Exception {} thrown by operation failure listener {}: {}-{}", new Object[]{
e.getClass(), listener.getName(), e.getMessage(), e });
parentResult.createSubresult(CLASS_NAME_WITH_DOT + "notifyFailure").recordWarning("Operation failure listener has thrown unexpected exception", e);
parentResult.createSubresult(CLASS_NAME_WITH_DOT + "notifyFailure")
.recordWarning("Operation failure listener has thrown unexpected exception", e);
}
}
} else {
Expand All @@ -190,25 +198,26 @@ public void notifyFailure(ResourceOperationDescription failureDescription,
* @see com.evolveum.midpoint.provisioning.api.ResourceObjectChangeListener#notifyFailure(com.evolveum.midpoint.provisioning.api.ResourceObjectShadowFailureDescription, com.evolveum.midpoint.task.api.Task, com.evolveum.midpoint.schema.result.OperationResult)
*/
@Override
public void notifySuccess(ResourceOperationDescription failureDescription,
public void notifySuccess(ResourceOperationDescription successDescription,
Task task, OperationResult parentResult) {
Validate.notNull(failureDescription, "Operation description of resource object shadow must not be null.");
Validate.notNull(successDescription, "Operation description of resource object shadow must not be null.");

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Resource operation success notification\n{} ", failureDescription.debugDump());
LOGGER.trace("Resource operation success notification\n{} ", successDescription.debugDump());
}

failureDescription.checkConsistence();
successDescription.checkConsistence();

if ((null != changeListeners) && (!changeListeners.isEmpty())) {
if ((null != operationListeners) && (!operationListeners.isEmpty())) {
for (ResourceOperationListener listener : new ArrayList<>(operationListeners)) { // sometimes there is registration/deregistration from within
//LOGGER.trace("Listener: {}", listener.getClass().getSimpleName());
try {
listener.notifySuccess(failureDescription, task, parentResult);
listener.notifySuccess(successDescription, task, parentResult);
} catch (RuntimeException e) {
LOGGER.error("Exception {} thrown by operation success listener {}: {}-{}", new Object[]{
e.getClass(), listener.getName(), e.getMessage(), e });
parentResult.createSubresult(CLASS_NAME_WITH_DOT + "notifySuccess").recordWarning("Operation success listener has thrown unexpected exception", e);
parentResult.createSubresult(CLASS_NAME_WITH_DOT + "notifySuccess")
.recordWarning("Operation success listener has thrown unexpected exception", e);
}
}
} else {
Expand All @@ -220,25 +229,26 @@ public void notifySuccess(ResourceOperationDescription failureDescription,
* @see com.evolveum.midpoint.provisioning.api.ResourceObjectChangeListener#notifyFailure(com.evolveum.midpoint.provisioning.api.ResourceObjectShadowFailureDescription, com.evolveum.midpoint.task.api.Task, com.evolveum.midpoint.schema.result.OperationResult)
*/
@Override
public void notifyInProgress(ResourceOperationDescription failureDescription,
public void notifyInProgress(ResourceOperationDescription inProgressDescription,
Task task, OperationResult parentResult) {
Validate.notNull(failureDescription, "Operation description of resource object shadow must not be null.");
Validate.notNull(inProgressDescription, "Operation description of resource object shadow must not be null.");

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Resource operation in-progress notification\n{} ", failureDescription.debugDump());
LOGGER.trace("Resource operation in-progress notification\n{} ", inProgressDescription.debugDump());
}

failureDescription.checkConsistence();
inProgressDescription.checkConsistence();

if ((null != changeListeners) && (!changeListeners.isEmpty())) {
if ((null != operationListeners) && (!operationListeners.isEmpty())) {
for (ResourceOperationListener listener : new ArrayList<>(operationListeners)) { // sometimes there is registration/deregistration from within
//LOGGER.trace("Listener: {}", listener.getClass().getSimpleName());
try {
listener.notifyInProgress(failureDescription, task, parentResult);
listener.notifyInProgress(inProgressDescription, task, parentResult);
} catch (RuntimeException e) {
LOGGER.error("Exception {} thrown by operation in-progress listener {}: {}-{}", new Object[]{
e.getClass(), listener.getName(), e.getMessage(), e });
parentResult.createSubresult(CLASS_NAME_WITH_DOT + "notifyInProgress").recordWarning("Operation in-progress listener has thrown unexpected exception", e);
parentResult.createSubresult(CLASS_NAME_WITH_DOT + "notifyInProgress")
.recordWarning("Operation in-progress listener has thrown unexpected exception", e);
}
}
} else {
Expand Down Expand Up @@ -281,7 +291,8 @@ public void notifyEvent(ResourceEventDescription eventDescription,
} catch (RuntimeException e) {
LOGGER.error("Exception {} thrown by event listener {}: {}-{}", new Object[]{
e.getClass(), listener.getName(), e.getMessage(), e });
parentResult.createSubresult(CLASS_NAME_WITH_DOT + "notifyEvent").recordWarning("Event listener has thrown unexpected exception", e);
parentResult.createSubresult(CLASS_NAME_WITH_DOT + "notifyEvent")
.recordWarning("Event listener has thrown unexpected exception", e);
throw e;
}
}
Expand Down

0 comments on commit 7dcb7c9

Please sign in to comment.