Hallo,
ich schlage mich zur Zeit mit einem Java-Agenten herum, der aus einem LDAP-Verzeichnisdienst etwa 28000 Einträge holt, diese zerlegt und entsprechende Dokumente in einer Notes-DB erstellt bzw. aktualisiert.
Auf meinem Client 8.5.1 unter XP läuft er super.
Auf dem Domino-Server 8.5FP1 unter Solaris SunOS 5.10 Generic_138888-05 fängt er etwa ab Datensatz 6200 an keine Ausgaben mehr ins Log zu schreiben. Dokumente werden auch nicht mehr geprüft.
Im Noteslog sieht das etwa so aus:
29.10.2009 10:37:34 AMgr: Agent ('LDAP_Vertreterdatenabgleich' in 'temp/VertDB44.nsf') printing: Cookie <> null
29.10.2009 10:37:44 AMgr: Agent ('LDAP_Vertreterdatenabgleich' in 'temp/VertDB44.nsf') printing: b = 6100
29.10.2009 10:37:54 AMgr: Agent ('LDAP_Vertreterdatenabgleich' in 'temp/VertDB44.nsf') printing: b = 6200
29.10.2009 10:37:54 AMgr: Agent ('LDAP_Vertreterdatenabgleich' in 'temp/VertDB44.nsf') printing: a = 31
29.10.2009 10:37:54 AMgr: Agent ('LDAP_Vertreterdatenabgleich' in 'temp/VertDB44.nsf') printing: Cookie <> null
...
29.10.2009 10:39:40 AMgr: Agent 'LDAP_Vertreterdatenabgleich' in 'temp/VertDB44.nsf' ran successfully; elapsed time was '69330' ticks
Wer hat eine Idee, was da passiert und warum keine Ausgaben mehr gemacht werden?
Für sachdienliche Hinweise gebe ich auf dem nächsten Entwicklercamp gerne einen aus ;-)
Danke schon mal für eure Hilfe
Martin
import lotus.domino.*;
import javax.naming.*;
import javax.naming.directory.*;
import java.io.IOException;
import java.util.Hashtable;
import javax.naming.ldap.*;
public class JavaAgent extends AgentBase {
static String result;
static String ivvAgencyArea = "";
static String ivvPVOccupationNumber = "";
static String postOfficeBox = "";
static String ivvOLFullNumber = "";
static String postalCode = "";
static String ivvRDFullNumber;
static String ivvAgentFullNumber = "";
static String ivvBranchOffice = "";
static String facsimileTelephoneNumber = "";
static String ivvPrimaryClientNumber = "";
static String telephoneNumber = "";
static String street = "";
static String l = "";
static String ivvAgent = "";
static String mail = "";
static String uid = "";
static String ivvNotesMail = "";
static String cn = "";
static String givenName = "";
static String employeeType = "";
static int a;
static int b;
static int c;
public static void findAttrs(Attributes attrs, Database db) {
// Attributwerte auslesen und ausgeben
cn = "";
result = "";
ivvAgencyArea = "";
ivvPVOccupationNumber = "";
postOfficeBox = "";
ivvOLFullNumber = "";
postalCode = "";
ivvRDFullNumber = "";
ivvAgentFullNumber = "";
ivvBranchOffice = "";
facsimileTelephoneNumber = "";
ivvPrimaryClientNumber = "";
telephoneNumber = "";
street = "";
l = "";
ivvAgent = "";
mail = "";
uid = "";
ivvNotesMail = "";
cn = "";
givenName = "";
employeeType = "";
try {
if (attrs.size() == 0) {
// tue nichts
} else {
try {
for (NamingEnumeration ae = attrs.getAll(); ae.hasMore()
{
c = c + 1;
Attribute attr = (Attribute) ae.next();
String attrId = attr.getID();
for (NamingEnumeration e = attr.getAll(); e.hasMore()
{
result = (String) e.next();
if (attrId.equals("ivvAgencyArea"))
ivvAgencyArea = result;
else if (attrId.equals("ivvAgentFullNumber")) {
ivvAgentFullNumber = result;
} else if (attrId.equals("ivvPVOccupationNumber"))
ivvPVOccupationNumber = result;
else if (attrId.equals("postOfficeBox"))
postOfficeBox = result;
else if (attrId.equals("ivvOLFullNumber"))
ivvOLFullNumber = result;
else if (attrId.equals("postalCode"))
postalCode = result;
else if (attrId.equals("ivvRDFullNumber"))
ivvRDFullNumber = result;
else if (attrId.equals("ivvBranchOffice"))
ivvBranchOffice = result;
else if (attrId.equals("facsimileTelephoneNumber")) {
if (result.endsWith("-")) {
result = result.substring(0, result
.length() - 1);
}
facsimileTelephoneNumber = result;
} else if (attrId.equals("ivvPrimaryClientNumber"))
ivvPrimaryClientNumber = result;
else if (attrId.equals("telephoneNumber")) {
if (result.endsWith("-")) {
result = result.substring(0, result
.length() - 1);
}
telephoneNumber = result;
} else if (attrId.equals("street"))
street = result;
else if (attrId.equals("l"))
l = result;
else if (attrId.equals("ivvAgent"))
ivvAgent = result;
else if (attrId.equals("mail"))
mail = result;
else if (attrId.equals("uid"))
uid = result;
else if (attrId.equals("ivvNotesMail"))
ivvNotesMail = result;
else if (attrId.equals("cn"))
cn = result;
else if (attrId.equals("givenName"))
givenName = result;
else if (attrId.equals("employeeType"))
employeeType = result;
else {
System.out.println("Key '" + attrId
+ "' nicht bekannt !");
}
}
}
} catch (NamingException e) {
System.out
.println("NamingException aufgetreten in findattrs");
e.printStackTrace();
}
} // end if
} catch (Exception e) {
System.out.println("Exception aufgetreten in FINDATTRS");
e.printStackTrace();
}
}
public static void findCN(NamingEnumeration enums, Database db) {
try {
if (enums.hasMore()) {
Document doc = null;
while (enums.hasMore()) {
b = b + 1;
SearchResult sr = (SearchResult) enums.next();
findAttrs(sr.getAttributes(), db);
if (uid != "") {
String suchstring = "[AID] CONTAINS " + "\"" + uid
+ "\"";
DocumentCollection col = db.FTSearch(suchstring);
if (col.getCount() > 0) {
// doc = col.getFirstDocument();
if (col.getCount() > 1) {
System.out.println("AID col > 1 - " + uid);
}
}
col = null;
} else {
String suchstring2 = "[NVTRNR] CONTAINS " + "\""
+ ivvAgentFullNumber
+ "\" AND NOT [AID] is present \"";
DocumentCollection col = db.FTSearch(suchstring2);
if (col.getCount() > 0) {
// doc = col.getFirstDocument();
if (col.getCount() > 1) {
System.out.println("NVTRNR col > 1");
}
}
col = null;
}
if (doc != null) {
// do nix ;
// } else {
doc = db.createDocument();
doc.replaceItemValue("NVTRNR", ivvAgentFullNumber);
doc.replaceItemValue("Form", "Vertreter");
doc.replaceItemValue("NTelefon", telephoneNumber);
doc
.replaceItemValue("NTELEX",
facsimileTelephoneNumber);
doc.replaceItemValue("NAnschrift", street);
doc.replaceItemValue("NName", ivvAgent);
doc.replaceItemValue("NPLZORT", postalCode + " " + l);
doc.replaceItemValue("email", mail);
doc.replaceItemValue("GST", ivvBranchOffice);
if (ivvPrimaryClientNumber.equals("01"))
doc.replaceItemValue("NUnternehmen",
"VGH Versicherungen");
else if (ivvPrimaryClientNumber.equals("02"))
doc.replaceItemValue("NUnternehmen",
"VGH Versicherungen");
else if (ivvPrimaryClientNumber.equals("24"))
doc.replaceItemValue("NUnternehmen",
"VGH Versicherungen");
else if (ivvPrimaryClientNumber.equals("06"))
doc.replaceItemValue("NUnternehmen",
"Öffentliche Versicherungen Bremen");
else if (ivvPrimaryClientNumber.equals("05"))
doc.replaceItemValue("NUnternehmen",
"Öffentliche Versicherungen Oldenburg");
else if (ivvPrimaryClientNumber.equals("11"))
doc.replaceItemValue("NUnternehmen",
"Öffentliche Versicherungen Oldenburg");
else if (ivvPrimaryClientNumber.equals("03"))
doc
.replaceItemValue("NUnternehmen",
"Öffentliche Versicherungen Sachsen-Anhalt");
else if (ivvPrimaryClientNumber.equals("04"))
doc
.replaceItemValue("NUnternehmen",
"Öffentliche Versicherungen Sachsen-Anhalt");
else
doc.replaceItemValue("NUnternehmen",
"Unternehmen nicht bekannt");
doc.replaceItemValue("Anwendergruppe", employeeType);
doc.replaceItemValue("Tätigkeitsschlüssel",
ivvPVOccupationNumber);
doc.replaceItemValue("CN", cn);
doc.replaceItemValue("AID", uid);
if (doc.save()) {
// if (uid.contains("")) {
// db.updateFTIndex(true);
System.out.println("Document gesichert");
// }
} else
System.out.println("Unable to save document");
}
int x = b;
if ((x % 100) == 0) {
System.out.println("b = " + b);
}
doc = null;
}
}
} catch (NamingException e) {
System.out.println("NamingException aufgetreten in FINDCN");
e.printStackTrace();
} catch (Exception e) {
System.out.println("Exception aufgetreten in FINDCN");
e.printStackTrace();
}
} // end of findCN
public void NotesMain() {
Database db;
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
System.out.println("Version = "
+ System.getProperty("java.vm.version"));
System.out.println("Version = " + System.getProperty("os.name"));
db = agentContext.getCurrentDatabase();
if (db.isFTIndexed()) {
System.out.println("db.isFTIndexed");
db.updateFTIndex(true);
String ldapCF = "com.sun.jndi.ldap.LdapCtxFactory";
String ldapURL = "ldap://IVVxxx:389/";
String ldapBaseDN = "o=ivv-verbund,c=DE";
String ldapUserID = "cn=xxx,cn=xxx,cn=xxx,o=xxx,c=DE";
String ldapPassword = "kennwort";
Hashtable env = new Hashtable(4);
env.put(Context.INITIAL_CONTEXT_FACTORY, ldapCF);
env.put(Context.PROVIDER_URL, ldapURL + ldapBaseDN);
env.put(Context.SECURITY_PRINCIPAL, ldapUserID);
env.put(Context.SECURITY_CREDENTIALS, ldapPassword);
String[] attrs = new String[18];
attrs[0] = "ivvAgentFullnumber";
attrs[1] = "telephoneNumber";
attrs[2] = "facsimileTelephoneNumber";
attrs[3] = "street";
attrs[4] = "postalCode";
attrs[5] = "ivvRDFullNumber";
attrs[6] = "ivvOLFullNumber";
attrs[7] = "ivvAgent";
attrs[8] = "postalCode";
attrs[9] = "l";
attrs[10] = "mail";
attrs[11] = "ivvBranchOffice";
attrs[12] = "ivvPrimaryClientNumber";
attrs[13] = "employeeType";
attrs[14] = "ivvPVOccupationNumber";
attrs[15] = "cn";
attrs[16] = "uid";
attrs[17] = "givenName";
try {
long startTime = System.currentTimeMillis();
LdapContext ctx = new InitialLdapContext(env, null);
int pageSize = 500;
byte[] cookie = null;
int total;
ctx
.setRequestControls(new Control[] { new PagedResultsControl(
pageSize, Control.NONCRITICAL) });
a = 0;
b = 0;
c = 0;
do {
SearchControls ctls = new SearchControls();
ctls.setReturningAttributes(attrs);
ctls.setSearchScope(2);
a = a + 1;
String filter = "(|(objectClass=ivvAgency)(&(|(objectClass=ivvSIActiveUser)(objectClass=ivvSIParentalLeaveUser))(&(ivvAgentNumber=*)(!(ivvAgentNumber=000000)))(|(uid=1*)(uid=2*))(!(|(ivvPrimaryClientNumber=14)(ivvPrimaryClientNumber=15)(ivvPrimaryClientNumber=16)(ivvPrimaryClientNumber=43)))))";
System.out.println("Cookie <> null");
NamingEnumeration answer = ctx.search("", filter, ctls);
while (answer != null && answer.hasMore()) {
findCN(answer, db);
System.out.println("a = " + a);
Control[] controls = ctx.getResponseControls();
if (controls != null) {
for (int i = 0; i < controls.length; i++) {
if (controls
instanceof PagedResultsResponseControl) {
PagedResultsResponseControl prrc = (PagedResultsResponseControl) controls;
total = prrc.getResultSize();
if (total != 0) {
System.out
.println("***************** END-OF-PAGE "
+ "(total : "
+ total
+ ") *****************\n");
} else {
System.out
.println("***************** END-OF-PAGE "
+ "(total: unknown) ***************\n");
}
cookie = prrc.getCookie();
}
}
} else {
System.out
.println("No controls were sent from the server");
}
ctx
.setRequestControls(new Control[] { new PagedResultsControl(
pageSize, cookie, Control.CRITICAL) });
}
} while (cookie != null);
ctx.close();
long endTime = System.currentTimeMillis();
System.out.print("LDAP_Vertreterdatenabgleich lief: ");
System.out.println(endTime - startTime);
} catch (NamingException e) {
e.printStackTrace();
System.out.println("Fehler aufgetreten in NamingException");
} catch (IOException e) {
e.printStackTrace();
System.out.println("Fehler aufgetreten in IOException");
}
}
} catch (Exception e) {
System.out.println("Fehler aufgetreten in Exception");
e.printStackTrace();
}
} // end of NotesMain
} // end of findAttrs
PS: Den Code hänge ich auch mal an, damit ihr euch ein Bild machen könnt.