Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core-edge: introduce a few more modules
Identity is now encapsulated behind the IdentityModule. Discovery is now encapsulated behind the ClusteringModule. MemberIdStorage now works slightly different as well and the simple functionality is now even further simplified and extracted to SimpleStorage.
- Loading branch information
1 parent
1d922f3
commit 736fa22
Showing
11 changed files
with
181 additions
and
88 deletions.
There are no files selected for viewing
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
77 changes: 77 additions & 0 deletions
77
enterprise/core-edge/src/main/java/org/neo4j/coreedge/core/IdentityModule.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,77 @@ | |||
/* | |||
* Copyright (c) 2002-2016 "Neo Technology," | |||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | |||
* | |||
* This file is part of Neo4j. | |||
* | |||
* Neo4j is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU Affero General Public License as | |||
* published by the Free Software Foundation, either version 3 of the | |||
* License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU Affero General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Affero General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
package org.neo4j.coreedge.core; | |||
|
|||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.UUID; | |||
|
|||
import org.neo4j.coreedge.core.state.storage.SimpleStorage; | |||
import org.neo4j.coreedge.identity.MemberId; | |||
import org.neo4j.io.fs.FileSystemAbstraction; | |||
import org.neo4j.kernel.impl.factory.PlatformModule; | |||
import org.neo4j.logging.Log; | |||
import org.neo4j.logging.LogProvider; | |||
|
|||
public class IdentityModule | |||
{ | |||
public static final String CORE_MEMBER_ID_NAME = "core-member-id"; | |||
private MemberId myself; | |||
|
|||
IdentityModule( PlatformModule platformModule, File clusterStateDirectory ) | |||
{ | |||
FileSystemAbstraction fileSystem = platformModule.fileSystem; | |||
LogProvider logProvider = platformModule.logging.getInternalLogProvider(); | |||
|
|||
Log log = logProvider.getLog( getClass() ); | |||
|
|||
SimpleStorage<MemberId> memberIdStorage = new SimpleStorage<>( fileSystem, clusterStateDirectory, | |||
CORE_MEMBER_ID_NAME, new MemberId.Marshal(), logProvider ); | |||
|
|||
try | |||
{ | |||
if ( memberIdStorage.exists() ) | |||
{ | |||
myself = memberIdStorage.readState(); | |||
if ( myself == null ) | |||
{ | |||
throw new RuntimeException( "I was null" ); | |||
} | |||
} | |||
else | |||
{ | |||
UUID uuid = UUID.randomUUID(); | |||
myself = new MemberId( uuid ); | |||
memberIdStorage.writeState( myself ); | |||
|
|||
log.info( String.format( "Generated new id: %s (%s)", myself, uuid ) ); | |||
} | |||
} | |||
catch ( IOException e ) | |||
{ | |||
throw new RuntimeException( e ); | |||
} | |||
} | |||
|
|||
MemberId myself() | |||
{ | |||
return myself; | |||
} | |||
} |
52 changes: 52 additions & 0 deletions
52
enterprise/core-edge/src/main/java/org/neo4j/coreedge/core/state/ClusteringModule.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,52 @@ | |||
/* | |||
* Copyright (c) 2002-2016 "Neo Technology," | |||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | |||
* | |||
* This file is part of Neo4j. | |||
* | |||
* Neo4j is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU Affero General Public License as | |||
* published by the Free Software Foundation, either version 3 of the | |||
* License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU Affero General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Affero General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
package org.neo4j.coreedge.core.state; | |||
|
|||
import org.neo4j.coreedge.discovery.CoreTopologyService; | |||
import org.neo4j.coreedge.discovery.DiscoveryServiceFactory; | |||
import org.neo4j.coreedge.identity.MemberId; | |||
import org.neo4j.kernel.configuration.Config; | |||
import org.neo4j.kernel.impl.factory.PlatformModule; | |||
import org.neo4j.kernel.impl.util.Dependencies; | |||
import org.neo4j.kernel.lifecycle.LifeSupport; | |||
import org.neo4j.logging.LogProvider; | |||
|
|||
public class ClusteringModule | |||
{ | |||
private final CoreTopologyService topologyService; | |||
|
|||
public ClusteringModule( DiscoveryServiceFactory discoveryServiceFactory, MemberId myself, PlatformModule platformModule ) | |||
{ | |||
LifeSupport life = platformModule.life; | |||
Config config = platformModule.config; | |||
LogProvider logProvider = platformModule.logging.getInternalLogProvider(); | |||
Dependencies dependencies = platformModule.dependencies; | |||
|
|||
topologyService = discoveryServiceFactory.coreTopologyService( config, myself, logProvider ); | |||
life.add( topologyService ); | |||
|
|||
dependencies.satisfyDependency( topologyService ); // for tests | |||
} | |||
|
|||
public CoreTopologyService topologyService() | |||
{ | |||
return topologyService; | |||
} | |||
} |
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
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
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
Oops, something went wrong.