Skip to Content.
Sympa Menu

grouper-users - [grouper-users] RE: Change Log Consumer

Subject: Grouper Users - Open Discussion List

List archive

[grouper-users] RE: Change Log Consumer


Chronological Thread 
  • From: "Klug, Lawrence" <>
  • To: Chris Hyzer <>, "" <>
  • Subject: [grouper-users] RE: Change Log Consumer
  • Date: Mon, 1 Oct 2012 21:47:05 +0000
  • Accept-language: en-US

Here is the PloneChangeLogConsumer class I’m working on:

 

/**

*

 */

package edu.internet2.middleware.grouper.changeLog.consumer;

 

import java.util.List;

import java.util.Map;

 

import org.apache.commons.logging.Log;

import org.apache.commons.lang.StringUtils;

 

import edu.internet2.middleware.grouper.Attribute;

import edu.internet2.middleware.grouper.Group;

import edu.internet2.middleware.grouper.GroupFinder;

import edu.internet2.middleware.grouper.GrouperSession;

import edu.internet2.middleware.grouper.log.EventLog;

 

import edu.internet2.middleware.grouper.util.GrouperUtil;

 

import edu.internet2.middleware.grouper.changeLog.ChangeLogConsumerBase;

import edu.internet2.middleware.grouper.changeLog.ChangeLogEntry;

import edu.internet2.middleware.grouper.changeLog.ChangeLogLabels;

import edu.internet2.middleware.grouper.changeLog.ChangeLogProcessorMetadata;

import edu.internet2.middleware.grouper.changeLog.ChangeLogTypeBuiltin;

 

/**

* @author lklug

*

*/

public class PloneChangeLogConsumer extends ChangeLogConsumerBase {

 

  private static final Log LOG = GrouperUtil.getLog(PloneChangeLogConsumer.class);

  private static final String PLONE_TARGET ="ploneTarget";

  private String stemPath = "";

  /* (non-Javadoc)

   * @see edu.internet2.middleware.grouper.changeLog.ChangeLogConsumerBase#processChangeLogEntries(java.util.List, edu.internet2.middleware.grouper.changeLog.ChangeLogProcessorMetadata)

   */

 

  @Override

  public long processChangeLogEntries(List<ChangeLogEntry> changeLogEntryList,

      ChangeLogProcessorMetadata changeLogProcessorMetadata) {

 

    long currentId = -1;

    String currentGroup = "";

   

    for (ChangeLogEntry changeLogEntry : changeLogEntryList) {

      LOG.info("**** PLONE CHANGE LOG CONSUMER ****");

      System.out.println("**** PLONE CHANGE LOG CONSUMER ****");

      //try catch so we can track that we made some progress

      try {

 

        currentId = changeLogEntry.getSequenceNumber();

 

        EventLog.info("Processing changeLog #" + currentId + ", "

            + changeLogEntry.getChangeLogType().getChangeLogCategory() + "."

            + changeLogEntry.getChangeLogType().getActionName()

            );

       

        System.out.println("Processing changeLog #" + currentId + ", "

            + changeLogEntry.getChangeLogType().getChangeLogCategory() + "."

            + changeLogEntry.getChangeLogType().getActionName()

            );

       

                     currentGroup = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.MEMBERSHIP_ADD.groupName);

                     stemPath = GrouperUtil.parentStemNameFromName(

                     changeLogEntry.retrieveValueForLabel(ChangeLogLabels.MEMBERSHIP_ADD.groupName));

       

       

                         

          GrouperSession gs =  GrouperSession.startRootSession(); 

          Group group =  GroupFinder.findByName(gs, currentGroup, false);

          Map<String, Attribute> myMap = group.getAttributesMap(false);

         

          for (Map.Entry<String, Attribute> entry : myMap.entrySet()) {

            String key = entry.getKey();

            LOG.info("Attribute Key = " + key);

            System.out.println("Attribute Key = " + key);

            Attribute attr = entry.getValue();

            if (attr.getAttrName().equalsIgnoreCase(PLONE_TARGET)) {

              notifyPlone(attr.getValue(), group.getName(), stemPath );

            }         

          }          

 

      } catch (Exception e) {

        //we unsuccessfully processed this record... decide whether to wait, throw, ignore, log, etc...

        LOG.error("problem with id: " + currentId, e);

        changeLogProcessorMetadata.setHadProblem(true);

        changeLogProcessorMetadata.setRecordException(e);

        changeLogProcessorMetadata.setRecordExceptionSequence(currentId);

        //stop here

        return currentId;

        //continue

      }

    }

 

    return currentId;

  }

 

 private void  notifyPlone(String attrValue, String groupName, String stemPath) {

// TODO Send notification to Plone

   LOG.info("NotifyPlone group = " + groupName + "/nploneTarget = " + attrValue + "/stemPath = " + stemPath);

   System.out.println("NotifyPlone group = " + groupName + "/nploneTarget = " + attrValue + "/stemPath = " + stemPath);

}

 

}

 

 

From: Chris Hyzer [mailto:]
Sent: Sunday, September 30, 2012 7:36 PM
To: Klug, Lawrence;
Subject: RE: Change Log Consumer

 

As events occur,  they are put into grouper_change_log_entry_temp table.

At the top of the minute, they are moved from there to the grouper_change_log_entry table.  If this is not occurring then the change log daemon in the loader is not running successfully.  At some point after that (e.g. a few seconds after the top of the minute), your change log consumer should run.  You should see a row for your consumer in the grouper_change_log_consumer table.  There will be a last index processed there which should be updated to the last grouper_change_log_entry index.  If that is not happening, then your consumer is not running.  If it is running, and not doing anything, then maybe it is not matching the records correctly… if you want to make a simple example change log consumer (something that I could load in my env), I could try to help troubleshoot, or let me know how you want to proceed.

 

Thanks,

Chris

 

From: Klug, Lawrence
Sent: Friday, September 28, 2012 12:36 PM
To: Chris Hyzer;
Subject: Change Log Consumer

 

So far I’m not seeing Admin UI events picked up by my ChangeLogConsumer class – do I need to configure something for this to happen?

 

Thanks,

 

Lawrence

 

 




Archive powered by MHonArc 2.6.16.

Top of Page