如何在Kafka的巡航控制中指定时间范围?

时间:2018-08-01 06:09:37

标签: apache-kafka cruisecontrol.net cruisecontrol cruisecontrol.rb

尝试访问对Apache Kafka具有巡航控制功能的API。  要打个电话,它说

  
      
  • 获取按给定资源利用率排序并按给定主题正则表达式和分区号/范围过滤的分区负载
       GET / kafkacruisecontrol / partition_load?resource = [RESOURCE]&start = [START_TIMESTAMP]&end = [END_TIMESTAMP]    &topic = [topic]&partition = [partition / start_partition-end_partition]
  •   

  
      
  • 注意:所有时间戳均为以秒为单位的纪元时间(在文档中给出)
  •   

这是我构造的URL(根据我的要求,我只需要开始和结束时间)

http://localhost:8081/kafkacruisecontrol/partition_load?start=1533101050920&end=1533102938311&json=true

当我遇到这个问题时,它会引发以下异常

<?php
include('config.php');
$fromDate = $_GET['from'];
$toDate = $_GET['to'];
$type = $_GET['type'];
$x = 1;
$total = 0;
$grandTotal = '';
$byData = mysqli_query($con,"CALL reportByDate('".$fromDate."','".$toDate."')") or die(mysqli_error($con));
if(mysqli_num_rows($byData)>0)
{
if($type=='all')
{
?>
    <table class="table table-bordered table-striped table-condensed">
        <thead>
        <tr>
            <th>#</th>
            <th class="numeric">Type</th>
            <th class="numeric">Token</th>
            <th class="numeric" style="width:15%">Patient Name</th>
            <th class="numeric">Age</th>
            <th class="numeric">Gender</th>
            <th class="numeric" style="width:12%">Refferred By</th>
            <th class="numeric" style="width:15%">Reff. By Address</th>
            <th class="numeric" style="width:13%">Purpose of visit</th>
            <th class="numeric">Amount</th>
            <th class="numeric" style="width:12%">Date</th>
            <th class="numeric">Time</th>
            <th class="numeric">Status</th>
        </tr>
        </thead>
<?php
while($byDataResult = mysqli_fetch_assoc($byData))
{
    $total = $total+$byDataResult['Amount'];

    ?>
    <tr>
        <td><?php echo $x; ?></td>
         <td><?php echo $byDataResult['ScanType']; ?></td>
        <td><?php echo $byDataResult['TokenYesterday']."/".$byDataResult['TokenToday'] ?></td>
        <td class="numeric"><?php echo $byDataResult['PatientName']; ?></td>
        <td class="numeric"><?php echo $byDataResult['Age']; ?></td>
        <td class="numeric"><?php echo $byDataResult['Sex']; ?></td>
        <td class="numeric"><?php echo $byDataResult['RefferredBy']; ?></td>
        <td class="numeric"><?php echo $byDataResult['ReffByAddress']; ?></td>
        <td class="numeric" style="width: 300px;"><?php echo substr($byDataResult['PurposeOfvisit'],0,100); ?></td>
        <td class="numeric"><?php echo number_format($byDataResult['Amount'],2); ; ?></td>
        <td class="numeric"><?php echo $byDataResult['Date']; ?></td>
        <td class="numeric"><?php echo $byDataResult['created_at']; ?></td>
        <td class="numeric" style="color: red;text-align: center;">
                                                <?php
                                                if( $byDataResult['Status']==2)
                                                {
                                                    echo 'Edited';
                                                }
                                                else{
                                                    echo "---";
                                                }

                                              ?></td>
    </tr>
    <?php
    $x++;
}
?>
        <tr class="totalRow">
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th style="text-align: right;">Total</th>
            <th><?php echo number_format($total,2); ?>/-</th>
            <th></th>
            <th></th>
            <th></th>

        </tr>
        </tbody>
    </table>
<?php
}
else{

    $x = 1;
$total = 0;
$grandTotal = '';

$byDataType = mysqli_query($con,"CALL reportByDateType('".$fromDate."','".$toDate."','".$type."')") or die(mysqli_error($con));
if(mysqli_num_rows($byDataType)>0){
    ?>
  <table class="table table-bordered table-striped table-condensed">
        <thead>
        <tr>
            <th>#</th>
            <th class="numeric">Type</th>
            <th class="numeric">Token</th>
            <th class="numeric" style="width:15%">Patient Name</th>
            <th class="numeric">Age</th>
            <th class="numeric">Gender</th>
            <th class="numeric" style="width:12%">Refferred By</th>
            <th class="numeric" style="width:15%">Reff. By Address</th>
            <th class="numeric" style="width:13%">Purpose of visit</th>
            <th class="numeric">Amount</th>
            <th class="numeric" style="width:12%">Date</th>
            <th class="numeric">Time</th>
            <th class="numeric">Status</th>
        </tr>
        </thead>
<?php
while($byDataResults = mysqli_fetch_assoc($byDataType))
{
    $total = $total+$byDataResults['Amount'];

    ?>
    <tr>
        <td><?php echo $x; ?></td>
         <td><?php echo $byDataResults['ScanType']; ?></td>
        <td><?php echo $byDataResults['TokenYesterday']."/".$byDataResults['TokenToday'] ?></td>
        <td class="numeric"><?php echo $byDataResults['PatientName']; ?></td>
        <td class="numeric"><?php echo $byDataResults['Age']; ?></td>
        <td class="numeric"><?php echo $byDataResults['Sex']; ?></td>
        <td class="numeric"><?php echo $byDataResults['RefferredBy']; ?></td>
        <td class="numeric"><?php echo $byDataResults['ReffByAddress']; ?></td>
        <td class="numeric"><?php echo substr($byDataResults['PurposeOfvisit'],0,100); ?></td>
        <td class="numeric"><?php echo number_format($byDataResults['Amount'],2); ; ?></td>
        <td class="numeric"><?php echo $byDataResults['Date']; ?></td>
        <td class="numeric"><?php echo $byDataResults['created_at']; ?></td>
        <td class="numeric" style="color: red;text-align: center;">
        <?php
        if( $byDataResults['Status']==2)
        {
            echo 'Edited';
        }
        else{
            echo "---";
        }

      ?></td>
    </tr>
    <?php
    $x++;
}
?>
        <tr class="totalRow">
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th style="text-align: right;">Total</th>
            <th><?php echo number_format($total,2); ?>/-</th>
            <th></th>
            <th></th>
            <th></th>

        </tr>
        </tbody>
    </table>


    <?php
    }
    else{
        ?>
         <h3 style="text-align: center">Sorry! No Record Found</h3>
        <?php
    }
}
}
else{
 ?>
    <h3 style="text-align: center">Sorry! No Record Found</h3>
<?php
}
    ?>

我想念东西吗?

供参考,这里是定速巡航API的git hub link

1 个答案:

答案 0 :(得分:0)

您遇到的异常似乎是this

在您指定的时间段内没有足够的有效窗口时,似乎会触发此事件。由于您指定的时间大约是30分钟,因此可能没有足够长的时间来发出此请求。

根据巡航控制readme

  

新经纪人的指标可能需要几分钟才能稳定下来。   Cruise Control会删除不一致的指标(例如,当主题   个字节的输入高于代理字节的输入),因此前几个快照   Windows可能没有足够的有效分区。

这也可能是相关的。在发出此请求之前,您已经运行集群多长时间了?