Issue #OS-131 Shard advisory for serialnum property#3
Conversation
| import java.util.Map; | ||
|
|
||
|
|
||
| public class AdvisoryLoader { |
There was a problem hiding this comment.
This name sounds generic. Let us call it ShardAdvisor and think of making the getShard(String property) as a static method. We expect this class to be initiated once.
There was a problem hiding this comment.
Named it as ShardAdvisorLoader:getShardAdvisory(String property)
|
|
||
| import io.opensaber.registry.model.DBConnectionInfo; | ||
|
|
||
| public interface IShardAdvisory { |
There was a problem hiding this comment.
IShardAdvisor that has a method getShard()
There was a problem hiding this comment.
IShardAdvisor has: DBConnectionInfo getShard(String attribute)
I hope this what you are expecting?
| } | ||
|
|
||
| @Override | ||
| public DBConnectionInfo connectionInfo(String subject) { |
There was a problem hiding this comment.
please rename subject as serialNumber to make it clear.
| @Autowired | ||
| AdvisoryLoader advisoryLoader; | ||
|
|
||
| public DatabaseProvider getInstance(String property, String value) throws IOException{ |
There was a problem hiding this comment.
I thought the DBShard just manages the connection. It does not need to know the attribute, value details. Given a shardId or connectionInfo, it merely gives initializes a provider. All this must either go to a separate class or this class be re-invented.
Treat DBShard as one that can just give a 'graph' instance, when you supply a connectionInfo.
Treat Advisor as one that merely advises the connectionInfo to be used for a given attribute value.
Treat X (to be invented) as one that can handle both the above classes and give you 'graph' instance.
…or serialNumber default
indrajra
left a comment
There was a problem hiding this comment.
Good going, few minor stuff. Fix them and we will merge.
| public DBConnectionInfo getShard(Object serialNumber) { | ||
|
|
||
| DBConnectionInfo connectionInfo = null; | ||
| if (serialNumber != null) { |
There was a problem hiding this comment.
I find this is too complex for an example. Why is a serialNumber not an integer?
if it is not because of schema definitions, lets correct it.
This must be a simple switch case, slNum % 2 == 0 implies it is even and so shard X; otherwise shard Y.
There was a problem hiding this comment.
Yes right kept it for some default shards. Done now.
|
|
||
| private Map<String,IShardAdvisor> advisors = new HashMap<String,IShardAdvisor>(); | ||
|
|
||
| public void registerAdvisor(String property, IShardAdvisor shardAdvisory){ |
| @RunWith(SpringRunner.class) | ||
| @SpringBootTest(classes = { RegistryDaoImpl.class, Environment.class, ObjectMapper.class, GenericConfiguration.class, | ||
| EncryptionServiceImpl.class, AuditRecordReader.class }) | ||
| EncryptionServiceImpl.class }) |
There was a problem hiding this comment.
undo this and the Autowired commented out few lines below.
| } | ||
|
|
||
| @Test | ||
| @Ignore @Test |
There was a problem hiding this comment.
are these must haves? otherwise please revert these changes.
…from local to sunbird
…eck_down_scenario
…health_check_down_scenario
Indroduced Shard advisor.
Added interface IShardAdvisory. Single sample impl for serial number property.
ShardAdvisor for registering the impl with property, this suppose to get pre loaded.
Shard factory intiatiate a connection with help of ShardAdvisor.
Introduced ShardManager to activate a Shard instance
TODO: