Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for checking store id on edge server startup
Now when the edge server startup of the local database is not empty it will check that its local store id is the same as the store id of one core server. In such a case the edge server is allowed to join the cluster otherwise it will not join by shutting down.
- Loading branch information
1 parent
d8ab022
commit 93e697d
Showing
26 changed files
with
640 additions
and
37 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
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
28 changes: 28 additions & 0 deletions
28
...ge/src/main/java/org/neo4j/coreedge/catchup/storecopy/StoreIdDownloadFailedException.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,28 @@ | ||
/* | ||
* 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.catchup.storecopy; | ||
|
||
public class StoreIdDownloadFailedException extends Exception | ||
{ | ||
public StoreIdDownloadFailedException( Throwable cause ) | ||
{ | ||
super( cause ); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...dge/src/main/java/org/neo4j/coreedge/catchup/storecopy/core/GetStoreIdRequestHandler.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,56 @@ | ||
/* | ||
* 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.catchup.storecopy.core; | ||
|
||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.channel.SimpleChannelInboundHandler; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import org.neo4j.coreedge.catchup.CatchupServerProtocol; | ||
import org.neo4j.coreedge.catchup.ResponseMessageType; | ||
import org.neo4j.coreedge.catchup.storecopy.edge.GetStoreIdRequest; | ||
import org.neo4j.coreedge.raft.replication.storeid.StoreIdMarshal; | ||
import org.neo4j.coreedge.server.StoreId; | ||
|
||
import static org.neo4j.coreedge.catchup.CatchupServerProtocol.NextMessage; | ||
|
||
public class GetStoreIdRequestHandler extends SimpleChannelInboundHandler<GetStoreIdRequest> | ||
{ | ||
private final CatchupServerProtocol protocol; | ||
private final Supplier<StoreId> storeIdSupplier; | ||
|
||
public GetStoreIdRequestHandler( CatchupServerProtocol protocol, Supplier<StoreId> storeIdSupplier ) | ||
{ | ||
this.protocol = protocol; | ||
this.storeIdSupplier = storeIdSupplier; | ||
} | ||
|
||
@Override | ||
protected void channelRead0( ChannelHandlerContext ctx, GetStoreIdRequest msg ) throws Exception | ||
{ | ||
StoreId storeId = storeIdSupplier.get(); | ||
ctx.writeAndFlush( ResponseMessageType.STORE_ID ); | ||
NetworkFlushableByteBuf channel = new NetworkFlushableByteBuf( ctx.alloc().buffer() ); | ||
StoreIdMarshal.marshal( storeId, channel ); | ||
ctx.writeAndFlush( channel.buffer() ); | ||
protocol.expect( NextMessage.MESSAGE_TYPE ); | ||
} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
.../core-edge/src/main/java/org/neo4j/coreedge/catchup/storecopy/edge/GetStoreIdRequest.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,28 @@ | ||
/* | ||
* 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.catchup.storecopy.edge; | ||
|
||
import org.neo4j.coreedge.catchup.RequestMessageType; | ||
import org.neo4j.coreedge.network.Message; | ||
|
||
public class GetStoreIdRequest implements Message | ||
{ | ||
public static final RequestMessageType MESSAGE_TYPE = RequestMessageType.STORE_ID; | ||
} |
52 changes: 52 additions & 0 deletions
52
...dge/src/main/java/org/neo4j/coreedge/catchup/storecopy/edge/GetStoreIdRequestDecoder.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,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.catchup.storecopy.edge; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import io.netty.buffer.Unpooled; | ||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.handler.codec.MessageToMessageDecoder; | ||
|
||
import java.util.List; | ||
|
||
import org.neo4j.coreedge.catchup.CatchupServerProtocol; | ||
|
||
public class GetStoreIdRequestDecoder extends MessageToMessageDecoder<ByteBuf> | ||
{ | ||
private final CatchupServerProtocol protocol; | ||
|
||
public GetStoreIdRequestDecoder( CatchupServerProtocol protocol ) | ||
{ | ||
this.protocol = protocol; | ||
} | ||
|
||
@Override | ||
protected void decode( ChannelHandlerContext ctx, ByteBuf msg, List<Object> out ) throws Exception | ||
{ | ||
if ( protocol.isExpecting( CatchupServerProtocol.NextMessage.GET_STORE_ID ) ) | ||
{ | ||
out.add( new GetStoreIdRequest() ); | ||
} | ||
else | ||
{ | ||
out.add( Unpooled.copiedBuffer( msg ) ); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...dge/src/main/java/org/neo4j/coreedge/catchup/storecopy/edge/GetStoreIdRequestEncoder.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,37 @@ | ||
/* | ||
* 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.catchup.storecopy.edge; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.handler.codec.MessageToMessageEncoder; | ||
|
||
import java.util.List; | ||
|
||
public class GetStoreIdRequestEncoder extends MessageToMessageEncoder<GetStoreIdRequest> | ||
{ | ||
@Override | ||
protected void encode( ChannelHandlerContext ctx, GetStoreIdRequest msg, List<Object> out ) throws Exception | ||
{ | ||
ByteBuf buffer = ctx.alloc().buffer(); | ||
buffer.writeByte( 0 ); | ||
out.add( buffer ); | ||
} | ||
} |
Oops, something went wrong.