-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added MastershipConfiguration for configuration management
- Loading branch information
1 parent
0dd3c1e
commit 3254f5d
Showing
4 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
...agerJava/src/org/mases/datadistributionmanager/configuration/MastershipConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2021 MASES s.r.l. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* Refer to LICENSE for more information. | ||
*/ | ||
|
||
package org.mases.datadistributionmanager.configuration; | ||
|
||
import org.mases.datadistributionmanager.CommonConfiguration; | ||
import org.mases.datadistributionmanager.IConfiguration; | ||
|
||
/** | ||
* The configuration class for mastership based on | ||
* DataDistributionMastershipManager | ||
*/ | ||
public class MastershipConfiguration extends CommonConfiguration { | ||
public static final String MastershipGlobalConfigurationBasePropertyKey = "datadistributionmanager.mastership."; | ||
|
||
/** | ||
* Duplicates a configuration | ||
* | ||
* @param originalConf {@link IConfiguration} to duplicate | ||
*/ | ||
public MastershipConfiguration(IConfiguration originalConf) { | ||
super(originalConf); | ||
setMastershipLibrary("DataDistributionMastershipManager.dll"); | ||
} | ||
|
||
/** | ||
* Duplicates a configuration | ||
* @param libraryName The mastership library name (or full path) to use | ||
* @param originalConf {@link IConfiguration} to duplicate | ||
*/ | ||
public MastershipConfiguration(String libraryName, IConfiguration originalConf) { | ||
super(originalConf); | ||
setMastershipLibrary("DataDistributionMastershipManager.dll"); | ||
} | ||
|
||
/** | ||
* Generic getter for all configuration properties | ||
* | ||
* @param property The property name | ||
* @return The property value | ||
*/ | ||
public String getProperty(String property) { | ||
String value = ""; | ||
if (property.startsWith(MastershipGlobalConfigurationBasePropertyKey)) { | ||
if (keyValuePair.containsKey(property)) | ||
value = keyValuePair.get(property); | ||
} else { | ||
if (keyValuePair.containsKey(MastershipGlobalConfigurationBasePropertyKey + property)) | ||
value = keyValuePair.get(MastershipGlobalConfigurationBasePropertyKey + property); | ||
} | ||
return value; | ||
} | ||
|
||
/** | ||
* Generic setter for all configuration properties | ||
* | ||
* @param property The property name | ||
* @param value The property value | ||
*/ | ||
public void setProperty(String property, String value) { | ||
if (property.startsWith(MastershipGlobalConfigurationBasePropertyKey)) { | ||
keyValuePair.put(property, value); | ||
} else { | ||
keyValuePair.put(MastershipGlobalConfigurationBasePropertyKey + property, value); | ||
} | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
src/DataDistributionManagerNet/Configuration/MastershipConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright 2021 MASES s.r.l. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* Refer to LICENSE for more information. | ||
*/ | ||
|
||
namespace MASES.DataDistributionManager.Bindings.Configuration | ||
{ | ||
/// <summary> | ||
/// The configuration class for mastership based on DataDistributionMastershipManager | ||
/// </summary> | ||
public class MastershipConfiguration : CommonConfiguration | ||
{ | ||
/// <summary> | ||
/// Base property name of all specific configuration key of <see cref="MastershipConfiguration"/> | ||
/// </summary> | ||
public const string MastershipGlobalConfigurationBasePropertyKey = "datadistributionmanager.mastership."; | ||
|
||
/// <summary> | ||
/// Duplicates a configuration | ||
/// </summary> | ||
/// <param name="originalConf"><see cref="IConfiguration"/> to duplicate</param> | ||
public MastershipConfiguration(IConfiguration originalConf) | ||
: base(originalConf) | ||
{ | ||
#if DEBUG | ||
MastershipLibrary = "DataDistributionMastershipManagerd.dll"; | ||
#else | ||
MastershipLibrary = "DataDistributionMastershipManager.dll"; | ||
#endif | ||
} | ||
|
||
/// <summary> | ||
/// Duplicates a configuration | ||
/// </summary> | ||
/// <param name="libraryName">The mastership library name (or full path) to use</param> | ||
/// <param name="originalConf"><see cref="IConfiguration"/> to duplicate</param> | ||
public MastershipConfiguration(string libraryName, IConfiguration originalConf) | ||
: base(originalConf) | ||
{ | ||
MastershipLibrary = libraryName; | ||
} | ||
|
||
/// <summary> | ||
/// Generic setter/getter for all configuration properties | ||
/// </summary> | ||
/// <param name="property">The property name</param> | ||
/// <returns>The property value</returns> | ||
public string this[string property] | ||
{ | ||
get | ||
{ | ||
string value = string.Empty; | ||
if (property.StartsWith(MastershipGlobalConfigurationBasePropertyKey)) | ||
{ | ||
keyValuePair.TryGetValue(property, out value); | ||
} | ||
else | ||
{ | ||
keyValuePair.TryGetValue(MastershipGlobalConfigurationBasePropertyKey + property, out value); | ||
} | ||
return value; | ||
} | ||
set | ||
{ | ||
if (property.StartsWith(MastershipGlobalConfigurationBasePropertyKey)) | ||
{ | ||
keyValuePair[property] = value; | ||
} | ||
else | ||
{ | ||
keyValuePair[MastershipGlobalConfigurationBasePropertyKey + property] = value; | ||
} | ||
EmitPropertyChanged(property); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters