src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java
/**
     * create new ephemeral path save to etcd .
     * if node disconnect from etcd, it will be deleted
     * automatically by etcd when sessian timeout.
     *
     * @param path the path to be saved
     * @return the lease of current path.
     */
create new ephemeral path save to etcd .
if node disconnect from etcd, it will be deleted
automatically by etcd when sessian timeout.

@param path the path to be saved
@return the lease of current path.
create new ephemeral path save to etcd . if node disconnect from etcd it will be deleted automatically by etcd when sessian timeout . @param path the path to be saved @return the lease of current path .
public long createEphemeral(String path) {
        for (; ; ) {
            try {
                long lease = client.getLeaseClient().grant(expirePeriod).get().getID();
                keepAlive(lease);
                client.getKVClient()
                        .put(ByteSequence.fromString(path)
                                , ByteSequence.fromString(String.valueOf(lease))
                                , PutOption.newBuilder().withLeaseId(lease).build()).get();
                return lease;
            } catch (Exception e) {
                Status status = Status.fromThrowable(e);
                if (status != null && status.getCode() == Status.Code.UNKNOWN) {
                    throw new IllegalStateException("failed to create ephereral by path '" + path + "'", e);
                }
                if (OptionUtil.isRecoverable(status)) {
                    LockSupport.parkNanos(this, TimeUnit.MILLISECONDS.toNanos(50));
                    continue;
                }
                throw new IllegalStateException(e.getMessage(), e);
            }
        }
    }
public long createEphemeral ( String path ) { for ( ; ; ) { try { long lease = client . getLeaseClient ( ) . grant ( expirePeriod ) . get ( ) . getID ( ) ; keepAlive ( lease ) ; client . getKVClient ( ) . put ( ByteSequence . fromString ( path ) , ByteSequence . fromString ( String . valueOf ( lease ) ) , PutOption . newBuilder ( ) . withLeaseId ( lease ) . build ( ) ) . get ( ) ; return lease ; } catch ( Exception e ) { Status status = Status . fromThrowable ( e ) ; if ( status != null && status . getCode ( ) == Status . Code . UNKNOWN ) { throw new IllegalStateException ( "failed to create ephereral by path '" + path + "'" , e ) ; } if ( OptionUtil . isRecoverable ( status ) ) { LockSupport . parkNanos ( this , TimeUnit . MILLISECONDS . toNanos ( 50 ) ) ; continue ; } throw new IllegalStateException ( e . getMessage ( ) , e ) ; } } }
create new ephemeral path save to etcd .
create new ephemeral path save to etcd .