Skip to content

Commit e6f80dd

Browse files
committed
LOCAL-LINSTOR: workaround fix for AllLinesParser getting stuck
1 parent b0d877d commit e6f80dd

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStoragePool.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
import org.apache.log4j.Logger;
3838
import org.joda.time.Duration;
3939

40+
import java.io.BufferedReader;
41+
import java.io.IOException;
42+
4043
public class LinstorStoragePool implements KVMStoragePool {
4144
private static final Logger s_logger = Logger.getLogger(LinstorStoragePool.class);
4245
private final String _uuid;
@@ -272,7 +275,7 @@ public Boolean checkingHeartBeat(HAStoragePool pool, HostTO host) {
272275
return checkHostUpToDateAndConnected(hostName);
273276
}
274277

275-
private String executeDrbdSetupStatus(OutputInterpreter.AllLinesParser parser) {
278+
private String executeDrbdSetupStatus(AllLinesParserLinstor parser) {
276279
Script sc = new Script("drbdsetup", Duration.millis(HeartBeatUpdateTimeout), s_logger);
277280
sc.add("status");
278281
sc.add("--json");
@@ -297,7 +300,7 @@ private boolean checkDrbdSetupStatusOutput(String output, String otherNodeName)
297300
return false;
298301
}
299302

300-
private String executeDrbdEventsNow(OutputInterpreter.AllLinesParser parser) {
303+
private String executeDrbdEventsNow(AllLinesParserLinstor parser) {
301304
Script sc = new Script("drbdsetup", Duration.millis(HeartBeatUpdateTimeout), s_logger);
302305
sc.add("events2");
303306
sc.add("--now");
@@ -314,7 +317,7 @@ private boolean checkDrbdEventsNowOutput(String output) {
314317

315318
private boolean checkHostUpToDateAndConnected(String hostName) {
316319
s_logger.trace(String.format("checkHostUpToDateAndConnected: %s/%s", localNodeName, hostName));
317-
OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser();
320+
AllLinesParserLinstor parser = new AllLinesParserLinstor();
318321

319322
if (localNodeName.equalsIgnoreCase(hostName)) {
320323
String res = executeDrbdEventsNow(parser);
@@ -342,4 +345,28 @@ public Boolean vmActivityCheck(HAStoragePool pool, HostTO host, Duration activit
342345
s_logger.trace(String.format("Linstor.vmActivityCheck: %s, %s", pool.getPoolIp(), host.getPrivateNetwork().getIp()));
343346
return checkingHeartBeat(pool, host);
344347
}
348+
349+
public static class AllLinesParserLinstor extends OutputInterpreter {
350+
String allLines = null;
351+
352+
@Override
353+
public String interpret(BufferedReader reader) throws IOException {
354+
StringBuilder builder = new StringBuilder();
355+
String line;
356+
while ((line = reader.readLine()) != null) {
357+
builder.append(line).append("\n");
358+
}
359+
allLines = builder.toString();
360+
return null;
361+
}
362+
363+
public String getLines() {
364+
return allLines;
365+
}
366+
367+
@Override
368+
public boolean drain() {
369+
return true;
370+
}
371+
}
345372
}

0 commit comments

Comments
 (0)