Java Code Examples for com.alibaba.dubbo.common.utils.IOUtils#appendLines()

The following examples show how to use com.alibaba.dubbo.common.utils.IOUtils#appendLines() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileGroup.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
public Peer join(URL url, ChannelHandler handler) throws RemotingException {
    Peer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[] {full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
Example 2
Source File: FileGroup.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Override
public void leave(URL url) throws RemotingException {
    super.leave(url);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        List<String> saves = new ArrayList<String>();
        for (String line : lines) {
            if (full.equals(line)) {
                return;
            }
            saves.add(line);
        }
        IOUtils.appendLines(file, saves.toArray(new String[0]));
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
}
 
Example 3
Source File: FileGroup.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Peer join(URL url, ChannelHandler handler) throws RemotingException {
    Peer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[] {full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
Example 4
Source File: FileExchangeGroup.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Override
public void leave(URL url) throws RemotingException {
    super.leave(url);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        List<String> saves = new ArrayList<String>();
        for (String line : lines) {
            if (full.equals(line)) {
                return;
            }
            saves.add(line);
        }
        IOUtils.appendLines(file, saves.toArray(new String[0]));
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
}
 
Example 5
Source File: FileExchangeGroup.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public ExchangePeer joinExchange(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangePeer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[] {full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
Example 6
Source File: FileGroup.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Override
public void leave(URL url) throws RemotingException {
    super.leave(url);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        List<String> saves = new ArrayList<String>();
        for (String line : lines) {
            if (full.equals(line)) {
                return;
            }
            saves.add(line);
        }
        IOUtils.appendLines(file, saves.toArray(new String[0]));
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
}
 
Example 7
Source File: FileGroup.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Peer join(URL url, ChannelHandler handler) throws RemotingException {
    Peer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[] {full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
Example 8
Source File: FileExchangeGroup.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Override
public void leave(URL url) throws RemotingException {
    super.leave(url);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        List<String> saves = new ArrayList<String>();
        for (String line : lines) {
            if (full.equals(line)) {
                return;
            }
            saves.add(line);
        }
        IOUtils.appendLines(file, saves.toArray(new String[0]));
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
}
 
Example 9
Source File: FileExchangeGroup.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public ExchangePeer joinExchange(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangePeer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[] {full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
Example 10
Source File: FileGroup.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@Override
public void leave(URL url) throws RemotingException {
    super.leave(url);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        List<String> saves = new ArrayList<String>();
        for (String line : lines) {
            if (full.equals(line)) {
                return;
            }
            saves.add(line);
        }
        IOUtils.appendLines(file, saves.toArray(new String[0]));
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
}
 
Example 11
Source File: FileExchangeGroup.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
public ExchangePeer joinExchange(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangePeer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[]{full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
Example 12
Source File: FileExchangeGroup.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@Override
public void leave(URL url) throws RemotingException {
    super.leave(url);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        List<String> saves = new ArrayList<String>();
        for (String line : lines) {
            if (full.equals(line)) {
                return;
            }
            saves.add(line);
        }
        IOUtils.appendLines(file, saves.toArray(new String[0]));
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
}
 
Example 13
Source File: FileExchangeGroup.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
public ExchangePeer joinExchange(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangePeer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[] {full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
Example 14
Source File: FileGroup.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Override
public void leave(URL url) throws RemotingException {
    super.leave(url);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        List<String> saves = new ArrayList<String>();
        for (String line : lines) {
            if (full.equals(line)) {
                return;
            }
            saves.add(line);
        }
        IOUtils.appendLines(file, saves.toArray(new String[0]));
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
}
 
Example 15
Source File: FileGroup.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Peer join(URL url, ChannelHandler handler) throws RemotingException {
    Peer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[] {full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
Example 16
Source File: FileExchangeGroup.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Override
public void leave(URL url) throws RemotingException {
    super.leave(url);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        List<String> saves = new ArrayList<String>();
        for (String line : lines) {
            if (full.equals(line)) {
                return;
            }
            saves.add(line);
        }
        IOUtils.appendLines(file, saves.toArray(new String[0]));
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
}
 
Example 17
Source File: FileExchangeGroup.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public ExchangePeer joinExchange(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangePeer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[] {full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
Example 18
Source File: FileGroup.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
public void leave(URL url) throws RemotingException {
    super.leave(url);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        List<String> saves = new ArrayList<String>();
        for (String line : lines) {
            if (full.equals(line)) {
                return;
            }
            saves.add(line);
        }
        IOUtils.appendLines(file, saves.toArray(new String[0]));
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
}
 
Example 19
Source File: FileGroup.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
public Peer join(URL url, ChannelHandler handler) throws RemotingException {
    Peer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[]{full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
Example 20
Source File: FileExchangeGroup.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
public void leave(URL url) throws RemotingException {
    super.leave(url);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        List<String> saves = new ArrayList<String>();
        for (String line : lines) {
            if (full.equals(line)) {
                return;
            }
            saves.add(line);
        }
        IOUtils.appendLines(file, saves.toArray(new String[0]));
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
}