Fix for 3914 : ServerState.reload() fails to update the ServerState
Fix ServerState.reload() and add a test case for this method.
Also take the chance to add some synchronization.
| | |
| | | */ |
| | | public void clear() |
| | | { |
| | | synchronized (this) |
| | | synchronized (list) |
| | | { |
| | | list.clear(); |
| | | } |
| | |
| | | |
| | | saved = false; |
| | | |
| | | synchronized(this) |
| | | synchronized(list) |
| | | { |
| | | Short id = changeNumber.getServerId(); |
| | | ChangeNumber oldCN = list.get(id); |
| | |
| | | |
| | | boolean result = false; |
| | | |
| | | clear(); |
| | | for (Short id : serverState) { |
| | | ChangeNumber maxChangeNumber = getMaxChangeNumber(id); |
| | | if (update(maxChangeNumber)) { |
| | | result = true; |
| | | synchronized (list) |
| | | { |
| | | clear(); |
| | | for (Short id : serverState) { |
| | | ChangeNumber maxChangeNumber = serverState.getMaxChangeNumber(id); |
| | | if (this.update(maxChangeNumber)) { |
| | | result = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | HashSet<String> set = new HashSet<String>(); |
| | | |
| | | synchronized (this) |
| | | synchronized (list) |
| | | { |
| | | for (Short key : list.keySet()) |
| | | { |
| | |
| | | { |
| | | ArrayList<ByteString> values = new ArrayList<ByteString>(0); |
| | | |
| | | synchronized (this) |
| | | synchronized (list) |
| | | { |
| | | for (Short id : list.keySet()) |
| | | { |
| | |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | |
| | | synchronized (this) |
| | | synchronized (list) |
| | | { |
| | | for (Short key : list.keySet()) |
| | | { |
| | |
| | | */ |
| | | public byte[] getBytes() throws UnsupportedEncodingException |
| | | { |
| | | synchronized (this) |
| | | synchronized (list) |
| | | { |
| | | int length = 0; |
| | | List<String> idList = new ArrayList<String>(list.size()); |
| | |
| | | public ServerState duplicate() |
| | | { |
| | | ServerState newState = new ServerState(); |
| | | synchronized (this) |
| | | synchronized (list) |
| | | { |
| | | for (Short key : list.keySet()) |
| | | { |
| | |
| | | ArrayList<Attribute> attributes = new ArrayList<Attribute>(); |
| | | attributes.add(Attributes.create("replicationServer-database", |
| | | String.valueOf(serverId))); |
| | | attributes.add(Attributes.create("base-dn", baseDn.toString())); |
| | | attributes.add(Attributes.create("domain-name", baseDn.toString())); |
| | | if (firstChange != null) |
| | | { |
| | | Date firstTime = new Date(firstChange.getTime()); |
| | |
| | | // Check getBytes |
| | | byte[] b = serverState.getBytes(); |
| | | ServerState generatedServerState = new ServerState(b,0,b.length -1) ; |
| | | |
| | | |
| | | |
| | | assertEquals(b, generatedServerState.getBytes()) ; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Create a new ServerState object |
| | | */ |
| | | @Test(dataProvider = "changeNumberData") |
| | | public void serverStateReloadTest(ChangeNumber cn) |
| | | throws Exception |
| | | { |
| | | ChangeNumber cn1, cn3; |
| | | cn1 = new ChangeNumber(cn.getTime()+1,cn.getSeqnum(),cn.getServerId()); |
| | | cn3 = new ChangeNumber(cn1.getTime(),cn1.getSeqnum(),(short)(cn1.getServerId()+1)); |
| | | |
| | | ServerState state1 = new ServerState(); |
| | | state1.update(cn1); |
| | | state1.update(cn3); |
| | | |
| | | ServerState state2 = new ServerState(); |
| | | state2.reload(state1); |
| | | |
| | | assertEquals(state1.toString(), state2.toString()) ; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Ensures that the Directory Server is able to |
| | | * translate a ruv entry to a sever state. |
| | | * |
| | |
| | | @DataProvider(name = "testSafeDataLevelHighProvider") |
| | | private Object[][] testSafeDataLevelHighProvider() |
| | | { |
| | | // Constrcut all possible combinations of parameters |
| | | // Construct all possible combinations of parameters |
| | | List<List<Object>> objectArrayList = new ArrayList<List<Object>>(); |
| | | |
| | | // Safe Data Level |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | |
| | | "-w", "password", |
| | | "-b", "cn=monitor", |
| | | "-s", "sub", |
| | | "(base-dn=*)" |
| | | "(domain-name=*)" |
| | | }; |
| | | |
| | | oStream.reset(); |