| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | import org.opends.messages.Message; |
| | |
| | | private ProtocolSession session; |
| | | private ServerHandler handler; |
| | | private ReplicationServerDomain replicationServerDomain; |
| | | private short serverId; |
| | | private short protocolVersion = -1; |
| | | |
| | | /** |
| | |
| | | ServerHandler handler, |
| | | ReplicationServerDomain replicationServerDomain) |
| | | { |
| | | super("Replication Writer for " + handler.toString() + " in RS " + |
| | | replicationServerDomain.getReplicationServer().getServerId()); |
| | | super("Replication Writer Thread for handler of " + |
| | | handler.toString() + |
| | | " in " + replicationServerDomain); |
| | | |
| | | this.serverId = serverId; |
| | | this.session = session; |
| | | this.handler = handler; |
| | | this.replicationServerDomain = replicationServerDomain; |
| | |
| | | */ |
| | | public void run() |
| | | { |
| | | Message errMessage = null; |
| | | if (debugEnabled()) |
| | | { |
| | | if (handler.isReplicationServer()) |
| | | { |
| | | TRACER.debugInfo("Replication server writer starting " + serverId); |
| | | } |
| | | else |
| | | { |
| | | TRACER.debugInfo("LDAP server writer starting " + serverId); |
| | | } |
| | | TRACER.debugInfo(this.getName() + " starting"); |
| | | } |
| | | try |
| | | { |
| | |
| | | { |
| | | UpdateMsg update = replicationServerDomain.take(this.handler); |
| | | if (update == null) |
| | | { |
| | | errMessage = Message.raw( |
| | | "Connection closure: null update returned by domain."); |
| | | return; /* this connection is closing */ |
| | | } |
| | | |
| | | /* Ignore updates in some cases */ |
| | | if (handler.isLDAPserver()) |
| | | if (handler.isDataServer()) |
| | | { |
| | | /** |
| | | * Ignore updates to DS in bad BAD_GENID_STATUS or FULL_UPDATE_STATUS |
| | |
| | | ", writer to " + this.handler.getMonitorInstanceName() + |
| | | " publishes msg=[" + update.toString() + "]"+ |
| | | " refgenId=" + referenceGenerationId + |
| | | " isAssured=" + update.isAssured() + |
| | | " server=" + handler.getServerId() + |
| | | " generationId=" + handler.getGenerationId()); |
| | | } |
| | |
| | | * The remote host has disconnected and this particular Tree is going to |
| | | * be removed, just ignore the exception and let the thread die as well |
| | | */ |
| | | Message message = NOTE_SERVER_DISCONNECT.get(handler.toString(), |
| | | errMessage = NOTE_SERVER_DISCONNECT.get(handler.toString(), |
| | | Short.toString(replicationServerDomain. |
| | | getReplicationServer().getServerId())); |
| | | logError(message); |
| | | logError(errMessage); |
| | | } |
| | | catch (SocketException e) |
| | | { |
| | |
| | | * The remote host has disconnected and this particular Tree is going to |
| | | * be removed, just ignore the exception and let the thread die as well |
| | | */ |
| | | Message message = NOTE_SERVER_DISCONNECT.get(handler.toString(), |
| | | errMessage = NOTE_SERVER_DISCONNECT.get(handler.toString(), |
| | | Short.toString(replicationServerDomain. |
| | | getReplicationServer().getServerId())); |
| | | logError(message); |
| | | logError(errMessage); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | * An unexpected error happened. |
| | | * Log an error and close the connection. |
| | | */ |
| | | Message message = ERR_WRITER_UNEXPECTED_EXCEPTION.get(handler.toString() + |
| | | errMessage = ERR_WRITER_UNEXPECTED_EXCEPTION.get(handler.toString() + |
| | | " " + stackTraceToSingleLineString(e)); |
| | | logError(message); |
| | | logError(errMessage); |
| | | } |
| | | finally { |
| | | try |
| | |
| | | // Can't do much more : ignore |
| | | } |
| | | replicationServerDomain.stopServer(handler); |
| | | |
| | | if (debugEnabled()) |
| | | { |
| | | if (handler.isReplicationServer()) |
| | | { |
| | | TRACER.debugInfo("Replication server writer stopping " + serverId); |
| | | } |
| | | else |
| | | { |
| | | TRACER.debugInfo("LDAP server writer stopping " + serverId); |
| | | } |
| | | TRACER.debugInfo(this.getName() + " stopped " + errMessage); |
| | | } |
| | | } |
| | | } |