Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you could look at a <code>Spring Batch</code> pattern where a single list of all users is built up, then, using a thread pool, each user is passed, modified and committed to the ldap server.</p> <p>a configuration might look like this;</p> <pre><code>&lt;batch:job id="ldapJob"&gt; &lt;batch:step id="ldapJob.step1"&gt; &lt;batch:tasklet task-executor="taskExecutor"&gt; &lt;batch:chunk reader="ldapReader" processor="ldapModifier" writer="ldapWriter" commit-interval="1"/&gt; &lt;/batch:tasklet&gt; &lt;/batch:step&gt; &lt;/batch:job&gt; &lt;task:executor id="taskExecutor"/&gt; </code></pre> <p>with the reader like this</p> <pre><code>package de.incompleteco.spring.batch.item.reader; import java.util.Queue; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.NonTransientResourceException; import org.springframework.batch.item.ParseException; import org.springframework.batch.item.UnexpectedInputException; import org.springframework.ldap.core.DirContextOperations; public class LdapItemReader implements ItemReader&lt;DirContextOperations&gt; { private Queue&lt;DirContextOperations&gt; dirContextOperations; public DirContextOperations read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { if (dirContextOperations == null) { synchronized (this) { //load up the dirContextOperations into the queue }//end synch }//end if //retrieve return dirContextOperations.poll(); } } </code></pre> <p>a processor;</p> <pre><code>package de.incompleteco.spring.batch.item.processor; import org.springframework.batch.item.ItemProcessor; import org.springframework.ldap.core.DirContextOperations; public class LdapItemProcessor implements ItemProcessor&lt;DirContextOperations, DirContextOperations&gt; { public DirContextOperations process(DirContextOperations item) throws Exception { //do some update item.setAttributeValue(null, null); //return return item; } } </code></pre> <p>and finally the writer to the ldap server</p> <pre><code>package de.incompleteco.spring.batch.item.writer; import java.util.List; import org.springframework.batch.item.ItemWriter; import org.springframework.ldap.core.DirContextOperations; import org.springframework.ldap.core.LdapTemplate; public class LdapItemWriter implements ItemWriter&lt;DirContextOperations&gt; { private LdapTemplate ldapTemplate; public void write(List&lt;? extends DirContextOperations&gt; items) throws Exception { for (DirContextOperations operation : items) { ldapTemplate.modifyAttributes(operation); } } public void setLdapTemplate(LdapTemplate ldapTemplate) { this.ldapTemplate = ldapTemplate; } } </code></pre> <p>the key thing in this pattern is the use of a taskexecutor to allow you to multi-thread the process, with the reader being responsible for first building the Queue/List (of 20k records) then each thread would poll for a user, make the changes, the put it back.</p> <p>this pattern doesn't allow for retries so you may want to look at the loading strategy, but it will give you a decent thread pool scalable update solution that can run in an WAR. </p> <p>have a look at <a href="http://static.springsource.org/spring-batch/reference/html-single/index.html" rel="nofollow">spring-batch</a> for more information</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload