-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
41 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import zk.zk as zk | ||
from pybase import * | ||
|
||
print zk.LocateMeta("localhost") | ||
a = NewClient("localhost") |
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,14 @@ | ||
import zk.zk as zk | ||
import region.region as region | ||
|
||
|
||
class Client: | ||
def __init__(self, zkquorum, client): | ||
self.zkquorum = zkquorum | ||
self.meta_client = client | ||
|
||
|
||
def NewClient(zkquorum): | ||
ip, port = zk.LocateMeta(zkquorum) | ||
meta_client = region.NewClient(ip, port) | ||
return Client(zkquorum, meta_client) |
Empty file.
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,25 @@ | ||
import socket | ||
from struct import pack, unpack | ||
from pb.RPC_pb2 import ConnectionHeader, UserInformation | ||
|
||
class Client: | ||
def __init__(self, host, port, sock): | ||
s.host = host | ||
s.port = port | ||
s.sock = sock | ||
|
||
|
||
def NewClient(host, port): | ||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
s.connect((host, port)) | ||
_send_hello(s) | ||
return | ||
|
||
|
||
def _send_hello(sock): | ||
ch = ConnectionHeader() | ||
ch.user_info.effective_user = "pybase" | ||
ch.service_name = "ClientService" | ||
serialized = ch.SerializeToString() | ||
message = "HBas\x00\x50" + pack(">I", len(serialized)) + serialized | ||
sock.send(message) |