cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alena Prokharchyk" <alena.prokharc...@citrix.com>
Subject Re: Review Request 17790: Domain-Account-User Sync Up Among Multiple Regions
Date Thu, 03 Apr 2014 22:39:19 GMT

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/17790/#review39482
-----------------------------------------------------------


Alex, all the fixes from the previous review, were done, thank you. But there are some more
to address:

1) Minor: Its a good practice shutdownNow() for your executors as a part of the server shutdownHook

Take for example:
FullSyncer.java

You have an _executor there; you have to call shutdownNow for it as a part of stop() method.
You can refer to ClusteredAgentManagerImpl for the example

2) Replace all of the hardcoded values like "account"/"domainId" you are getting when parse
API requests from CS, with the references to ApiConstants.

3) Replace generic Exception for "not implemented" cases in places like below, with CS UnsupportedException:

public JSONObject deleteAccountFromProject() throws Exception {
158
        throw new Exception("Not implemented");
159
    }


4) :) Use StringBuilder for String concatination (BaseInterface.java, and may be some other
classes)

if (paramStr != null && !paramStr.equals(""))
98
            connUrl += "?" + paramStr;


5) Rename BaseInterface.java, its not an interface. Rename is with some name meaningful to
your component.
Same for DomainInterface/AccountInterface. all the classes that are not interfaces.


6) Back to StringBuilder. Replace

StringBuilder param = new StringBuilder("command=createDomain&name=" + name + "&response=json&sessionkey="
+ encodeSessionKey());
if (parentDomainId != null) param.append("&parentdomainid=" + parentDomainId);

with

StringBuilder param = new StringBuilder("command=createDomain&name=").append(name).append("&response=json&sessionkey=").append(encodeSessionKey());
if (parentDomainId != null) param.append("&parentdomainid=").append(parentDomainId);

Just search for all + occurance for your string, and put a replacement


7) My suggestion for you would be: build your commands in generic manner. For example, create
some helper method with the signature:

buildCommand(String commandName, Map<String, String> parameters) {
    StringBuilder param = new StringBuilder("command=).append(commandName).append("&response=json&sessionkey=").append(encodeSessionKey());
    ...
    go through parameters list to form the request
}


8) Whenever possible, try to use interface instead of VO class. For example, Account vs AccountVO.
Only if Account misses some fiels that you need, use AccountVO.

9) AccountFullSyncProcesser. What is the reason for the code swallowing a generic exception
like this? Its not a good practice

 for (int idx = 0; idx < remoteArray.length(); idx++) {
93
            try {
94
                remoteList.add(remoteArray.getJSONObject(idx));
95
            } catch (Exception ex) {
96
97
            }
98
        }



10) AccountFullSync

 catch (Exception ex) {
118
            s_logger.error("Failed to synchronize accounts : " + ex.getMessage());
119
        }

exception is logged incorrectly, should be logged like:

s_logger.error("Failed to synchronize accounts : ", ex;

I've seen the similar in other places; please replace everywhere


11) On Exceptions. I can see that you throw generic Exception everywhere. Try to replace them
with more specific exceptions reflecting reason for the failure. Look at CS existing exceptions
- PermissionDeniedException,InvalidParameterValueException/CloudRuntimeException, and try
to utilize them.

12) Please compare accountNames (and other string values) in case insensitive manner. Use
equalsignorecase instead of equals


- Alena Prokharchyk


On April 3, 2014, 3:54 p.m., Alex Ough wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/17790/
> -----------------------------------------------------------
> 
> (Updated April 3, 2014, 3:54 p.m.)
> 
> 
> Review request for cloudstack.
> 
> 
> Repository: cloudstack-git
> 
> 
> Description
> -------
> 
> Currently, under the environment of cloudstack with multiple regions, each region has
its own management server running with a separate database, which will cause data discrepancies
when users create/update/delete domain/account/user data independently in each management
server. So to support multiple regions and provide one point of entry for each customer, this
implementation duplicates domain/account/user information of customers in one region to all
of the regions independently whenever there is any change.
> 
> https://issues.apache.org/jira/browse/CLOUDSTACK-4992
> https://cwiki.apache.org/confluence/display/CLOUDSTACK/Domain-Account-User+Sync+Up+Among+Multiple+Regions
> 
> 
> Diffs
> -----
> 
>   plugins/event-bus/multiregion/pom.xml PRE-CREATION 
>   plugins/event-bus/multiregion/resources/META-INF/cloudstack/spring-mom-multiregion-daos-context.xml
PRE-CREATION 
>   plugins/event-bus/multiregion/resources/META-INF/cloudstack/system/spring-plugin-multiregion-system-context.xml
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/FullSyncer.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/InjectedCollection.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/MultiRegionEventBus.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/api/AccountInterface.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/api/BaseInterface.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/api/DomainInterface.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/api/UserInterface.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/AccountFullSyncProcessor.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/AccountService.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/BaseService.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/DomainFullSyncProcessor.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/DomainService.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/FullScanner.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/FullSyncProcessor.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/LocalAccountManager.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/LocalDomainManager.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/LocalUserManager.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/RemoteAccountEventProcessor.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/RemoteDomainEventProcessor.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/RemoteEventProcessor.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/RemoteUserEventProcessor.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/UserFullSyncProcessor.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/service/UserService.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/simulator/SimulatorAccountLocalGenerator.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/simulator/SimulatorAccountLocalGeneratorEvent.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/simulator/SimulatorAutoGenerator.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/simulator/SimulatorDomainLocalGenerator.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/simulator/SimulatorDomainLocalGeneratorEvent.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/simulator/SimulatorLocalGenerator.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/simulator/SimulatorUserLocalGenerator.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/simulator/SimulatorUserLocalGeneratorEvent.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/subscriber/AccountSubscriber.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/subscriber/DomainSubscriber.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/subscriber/MultiRegionSubscriber.java
PRE-CREATION 
>   plugins/event-bus/multiregion/src/org/apache/cloudstack/mom/multiregion/subscriber/UserSubscriber.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/api/AccountInterfaceTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/api/BaseInterfaceTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/api/DomainInterfaceTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/api/UserInterfaceTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/service/AccountFullSyncProcessorTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/service/BaseServiceTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/service/DomainFullSyncProcessorTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/service/RemoteAccountEventProcessorTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/service/RemoteDomainEventProcessorTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/service/RemoteUserEventProcessorTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/service/UserFullSyncProcessorTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/simulator/SimulatorAccountLocalGeneratorEventTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/simulator/SimulatorAccountLocalGeneratorTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/simulator/SimulatorDomainLocalGeneratorEventTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/simulator/SimulatorDomainLocalGeneratorTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/simulator/SimulatorLocalGeneratorTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/simulator/SimulatorUserLocalGeneratorEventTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/simulator/SimulatorUserLocalGeneratorTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/subscriber/AccountSubscriberTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/subscriber/DomainSubscriberTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/subscriber/MultiRegionSubscriberTest.java
PRE-CREATION 
>   plugins/event-bus/multiregion/test/org/apache/cloudstack/mom/multiregion/subscriber/UserSubscriberTest.java
PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/17790/diff/
> 
> 
> Testing
> -------
> 
> 1. Successfully tested real time synchronization as soon as resources are created/deleted/modified
in one region.
> 2. Successfully tested full scans to synchronize resources that were missed during real
time synchronization because of any reasons like network connection issues.
> 3. The tests were done manually and also automatically by randomly generating changes
each region.
> 
> 
> Thanks,
> 
> Alex Ough
> 
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message