Peergroups
This presentation is the property of its rightful owner.
Sponsored Links
1 / 18

Peergroups PowerPoint PPT Presentation


  • 59 Views
  • Uploaded on
  • Presentation posted in: General

Peergroups. Learning Objectives. This module will teach you how to manipulate groups How to join a group How to publish and discover groups How to create a new group How to create secure groups. Creating Peergroup ID. If you need to create a peergroup, all peers must use same peergroup ID

Download Presentation

Peergroups

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Peergroups

Peergroups


Learning objectives

Learning Objectives

  • This module will teach you how to manipulate groups

    • How to join a group

    • How to publish and discover groups

    • How to create a new group

    • How to create secure groups


Creating peergroup id

Creating Peergroup ID

  • If you need to create a peergroup, all peers must use same peergroup ID

  • In general, use pre-defined string

  • Can use JXTA Shell to generate string:

    JXTA> mkpgrp mygroup

    JXTA> groupsgroup0: name = mygroup

    JXTA> cat group0...<GID>urn:jxta:uuid-71A8EC0B31BA471BB053B287211BC75602</GID>....


Publishing peergroups

Publishing Peergroups

  • Peergroups are automatically published locally when they are created

    • Published with default expiration values

    • No need to explicitly call DiscoveryService.publish()

  • To remotely publish a peergroup

    • Call DiscoveryService.remotePublish


Joining peergroups

Joining Peergroups

  • Membership Service

    • Used to apply for peergroup membership, join a peergroup, and resign from a peergroup

    • Enables peer to establish an identity within a peergroup

    • Identities used by services to determine the capabilities which should be offered peers


Sequence of establishing identity

Sequence of Establishing Identity

  • Apply

    • Peer provides membership service an initial credential; service returns an authenticator object

  • Join

    • The completed authenticator is returned to the membership service and the identity of the peer is adjusted

  • Resign

    • The existing identity for this peer is discarded


Secure peergroups

Secure Peergroups

  • Need to assign a secure membership service to the peergroup

    • Decentralized (Peergroup certificates)

    • Centralized (LDAP authentication server)

  • Define principal roles in the peergroup

    • Read only – read/write access

    • Act as relay or rendezvous

    • etc.

  • Peergroup advertisement publishing scope


Peergroup java api

Peergroup – Java API

Creating & Publishing Peergroups

getAllPurposePeerGroupImplAdvertisement()

  • Get an allPurpose peerGroup ModuleImplAdvertisement compatible with this group.

    newGroup(Advertisement pgAdv)newGroup(PeerGroupID pgID)newGroup(PeerGroupID gid, Advertisement impl, java.lang.String name, java.lang.String descr)

  • Create a new group and publish it.

    publishGroup(java.lang.String name, java.lang.String descr)

  • Force publication of the group if it hasn't already been done.


Membership service java api

Membership Service – Java API

Joining Peergroups

apply(AuthenticationCredential application)

  • Request the necessary credential to join the group with which this service is associated.

    getAuthCredentials()getCurrentCredentials()

  • Returns the current credentials for this peer

    join(Authenticator authenticated)

  • Join the group by the virtue of the complete authentication provided.

    makeCredential(Element element)

  • Given a fragment of a StructuredDocument, reconstruct a Credential object from that fragment.

    resign()

  • Leave the group to which this service is attached.


Create a peergroup java

Create a Peergroup— Java

private PeerGroup createGroup() {

PeerGroupAdvertisement adv;

System.out.println("Creating a new group advertisement");

try {

// create a new all purpose peergroup.

ModuleImplAdvertisement implAdv =

myGroup.getAllPurposePeerGroupImplAdvertisement();

PeerGroup pg = myGroup.newGroup(null, // Assign new group ID

implAdv, // The implem. adv

"PubTest", // Group name

"testing group adv"); // Helpful descr.

// print the name of the group and the peer group ID

adv = pg.getPeerGroupAdvertisement();

PeerGroupID GID = adv.getPeerGroupID();

System.out.println(" Group = " +adv.getName() +

"\n Group ID = " + GID.toString());

} catch (Exception e) {

System.out.println("Group creation failed with " + e.toString());

return null;

}

try {

// publish this advertisement (send to other peers, rdv peers)

discovery.publish(adv, DiscoveryService.GROUP,

PeerGroup.DEFAULT_LIFETIME,

PeerGroup.DEFAULT_EXPIRATION);

discovery.remotePublish(adv, DiscoveryService.GROUP);

System.out.println("Group published successfully.");

} catch (IOException e) {

System.out.println("Error publishing group advertisement");

e.printStackTrace();

}

return(pg);

}


Join a peergroup java

Join a Peergroup—Java

private void joinGroup(PeerGroup grp) {

StructuredDocument creds = null;

try {

// Generate the credentials for the Peer Group

AuthenticationCredential authCred =

new AuthenticationCredential( grp, null, creds );

// Get the MembershipService from the peer group

MembershipService membership = grp.getMembershipService();

// Get the Authenticator from the Authentication creds

Authenticator auth = membership.apply( authCred );

// All authenticators besides 'Null' require you to do something here.

// Check if everything is okay to join the group

if (auth.isReadyForJoin()){

Credential myCred = membership.join(auth);

System.out.println("Joined group " + grp.getPeerGroupName());

// display the credential as a plain text document.

System.out.println("\nCredential: ");

StructuredTextDocument doc = (StructuredTextDocument)

myCred.getDocument(new MimeMediaType("text/plain"));

StringWriter out = new StringWriter();

doc.sendToWriter(out);

System.out.println(out.toString());

out.close();

}

else

System.out.println("Failure: unable to join group");

}

catch (Exception e){

System.out.println("Failure in authentication.");

}

}


Peergroup service c api

Peergroup Service – C API

Registering and Accessing Peergroups

jxta_register_group_instance (Jxta_id *gid, Jxta_PG *pg)

  • This method registers a group instance.

    jxta_unregister_group_instance (Jxta_id *gid, Jxta_PG *pg)

  • This method unregisters a group instance.

    jxta_lookup_group_instance (Jxta_id *gid, Jxta_PG **pg)

  • This method is used to access a child peergroup instance

    jxta_PG_get_GID(Jxta_PG* self, Jxta_PGID** gid)

  • This method is used to access the peergroup ID

    jxta_PG_get_PID(Jxta_PG* self, Jxta_PID** pid)

  • This method is used to access peerid

    jxta_PG_get_groupname(Jxta_PG* self, JString** gname)

  • This method is used to access the peergroup name


Peergroup service c api1

Peergroup Service – C API

Accessing Peergroup Services

jxta_PG_get_endpoint_service(Jxta_PG* self,Jxta_endpoint_service** endp)

  • This method is used to access the peergroup endpoint service

    jxta_PG_get_rendezvous_service(Jxta_PG* self,Jxta_rdv_service** rdv)

  • This method is used to access the peergroup rendezvous service

    jxta_PG_get_discovery_service(Jxta_PG* self,Jxta_discovery_service** disco)

  • This method is used to access the peergroup discovery service

    jxta_PG_get__membership_service(Jxta_PG* self,Jxta_membership_service** membership)

  • This method is used to access the peergroup membership service

    jxta_PG_get_pipe_service(Jxta_PG* self, Jxta_pipe_service** pipe)

  • This method is used to access the peergroup pipe service

    jxta_PG_get_resolver_service(Jxta_PG* self, Jxta_resolver_service** resolver)

  • This method is used to access the peergroup resolver service

    jxta_PG_get_peerinfo_service(Jxta_PG* self, Jxta_peerinfo_service** peerinfo)

  • This method is used to access the peerinfo pipe service


Peergroup service c api2

Peergroup Service – C API

Creating Peergroups

jxta_PG_newfromadv (Jxta_PG *self, Jxta_advertisement *pgAdv Jxta_vector *resource_groups, Jxta_PG **result)

  • Instantiate a group from its given advertisement Use this when a published implementation advertisement for the group sub-class can be discovered.

    jxta_PG_newfromimpl (Jxta_PG *self, Jxta_PGID *gid, jxta_advertisement *impl, JString *name, JString *description, Jxta_vector *resource_groups, Jxta_PG **result)

  • Convenience method, instantiate a group from its elementary pieces and publish the corresponding peer group advertisement.

    jxta_PG_newfromid (Jxta_PG *self, Jxta_PGID *gid, Jxta_vector *resource_groups, Jxta_PG **result)

  • Instantiate a group from its group ID only.


Join a group c

Join a Group—C

Jxta_PG * newPG = NULL;

Jxta_PGA * pga = NULL

/* Discover advertisement of the group we are looking to join */

jxta_PG_get_discovery_service(group, &discovery);

discovery_service_get_local_advertisements(discovery,

DISC_GROUP,

(char *)jstring_get_string(attr),

(char *)jstring_get_string(value),

& res_vec);

if (res_vec != NULL ) {

for (i=0; i < jxta_vector_size(res_vec); i++ ){

jxta_vector_get_object_at (res_vec, (Jxta_object**)&pga, i);

JXTA_OBJECT_SHARE(pga);

} else {

// No group advertisements retrieved

}

/* Reuse the resource groups of our parent. */

jxta_PG_get_resourcegroups( group, &resources );

/* add the new group's parent */

jxta_vector_add_object_last( resources, (Jxta_object*) group );

res = jxta_PG_newfromadv ( group, (Jxta_advertisement*) pga, resources, &newPG );


Join a group c continued

Join a Group—C (continued)

if( res == JXTA_SUCCESS ) {

// Group correctly joined

}

/* looking for a rendezvous */

jxta_PG_get_GID( newPG, &gid );

jxta_id_to_jstring( gid, &gidstr );

while( iterations < 20 ) {

//Searching for Rendezvous

/* flush */

if( 0 == (iterations % 3) ) {

int qid = discovery_service_get_remote_advertisements(discovery,

NULL,

DISC_ADV,

"RdvGroupId",

jstring_get_string(gidstr),

5,

NULL);

}

/* nap a while */

jpr_thread_delay( 5 * 1000 * 1000 );


Join a group c continued1

Join a Group—C (continued)

discovery_service_get_local_advertisements(discovery,

DISC_ADV,

"RdvGroupId",

jstring_get_string(gidstr),

& res_vec);

if (res_vec != NULL ) {

int i;

for (i=0; i < jxta_vector_size(res_vec); i++ ) {

Jxta_RdvAdvertisement * rdvAdv = NULL;

jxta_vector_get_object_at ( res_vec, (Jxta_object**)&rdvAdv, i);

if( NULL != rdvAdv )

jid = jxta_RdvAdvertisement_get_RdvPeerId( rdvAdv );

jxta_id_get_uniqueportion( jid, &jidstr );

addr_e = jxta_endpoint_address_new( (char*) jstring_get_string(jidstr));

jxta_PG_get_rendezvous_service( (Jxta_PG*) group, &rdv );

jxta_peer_set_address (peer, addr_e);

jxta_rdv_service_add_peer( (Jxta_rdv_service*) rdv, peer);

break;

}

}

/* To resign from a peergroup */

Jxta_membership_service * membership;

jxta_PG_get_membership_service( group, &membership );

if( NULL != membership ) {

jxta_membership_service_resign( membership );

}

}


Peergroups

End – Peergroups


  • Login