/** * Algorithm to sequentially generate pathIds. * * <p> * @return Pathid or error if none available */ public static int generatePathIdSequentialIncrements() { int pathid; int count = num_pathid; do { next_pathid = next_pathid + 1; pathid = MIN_PATH_ID + next_pathid; if (check_suitable_pathid(pathid) && allocate_pathid(pathid)) { return pathid; } count--; } while (count > 0); return -1; }
/** * Check and allocate Pathid if available * * <p> * @param pathid Candidate Path Id * @return True if allocated, otherwise false. */ public static long check_and_allocate_pathid(long pathid) { if (SfcConcurrencyAPI.getPathIdLock()) { try { if (check_suitable_pathid(pathid) && allocate_pathid(pathid)) { return pathid; } else { return -1; } } finally { SfcConcurrencyAPI.releasePathIdLock(); } } else { return -1; } }
/** * Generate pathid, check and allocate if available * * <p> * @return True if allocated, otherwise false. */ public static long check_and_allocate_pathid() { if (SfcConcurrencyAPI.getPathIdLock()) { try { long pathId = -1; GenerationAlgorithmEnum genAlg = getGenerationAlgorithm(); if(genAlg == GenerationAlgorithmEnum.Random) { pathId = generatePathIdRandomIncrements(); } else if(genAlg == GenerationAlgorithmEnum.Sequential) { pathId = generatePathIdSequentialIncrements(); } if ((pathId >= MIN_PATH_ID) && allocate_pathid(pathId)) { return pathId; } else { return -1; } } finally { SfcConcurrencyAPI.releasePathIdLock(); } } else { return -1; } }
if ((symmetric_id >= MIN_PATH_ID) && allocate_pathid(symmetric_id)) { return symmetric_id; } else {