text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package kafka.manager
import java.nio.charset.StandardCharsets
import java.text.NumberFormat
/**
* @author hiral
*/
package object utils {
import org.json4s._
import org.json4s.ja... | fim | yahoo/CMAK | scala |
<|fim_suffix|>op -> KafkaConfig.LogPreAllocateProp,
MessageFormatVersionProp -> KafkaConfig.LogMessageFormatVersionProp,
MessageTimestampTypeProp -> KafkaConfig.LogMessageTimestampTypeProp,
MessageTimestampDifferenceMaxMsProp -> KafkaConfig.LogMessageTimestampDifferenceMaxMsProp,
MessageDownConversionEn... | fim | yahoo/CMAK | scala |
<|fim_suffix|> = "protocol_type"
private val GENERATION_KEY = "generation"
private val PROTOCOL_KEY = "protocol"
private val LEADER_KEY = "leader"
private val CURRENT_STATE_TIMESTAMP_KEY = "current_state_timestamp"
private val MEMBERS_KEY = "members"
private val GROUP_METADATA_VALUE_SCHEMA_V0 = new Schema(... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the ... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the ... | fim | yahoo/CMAK | scala |
<|fim_suffix|>DifferenceMaxMsProp = "message.timestamp.difference.max.ms"
val LeaderReplicationThrottledReplicasProp = "leader.replication.throttled.replicas"
val FollowerReplicationThrottledReplicasProp = "follower.replication.throttled.replicas"
val SegmentSizeDoc = "This configuration controls the segment fil... | fim | yahoo/CMAK | scala |
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the ... | fim | yahoo/CMAK | scala |
<|fim_suffix|>ionBytesProp).toLong,
retentionMs = props.getProperty(RententionMsProp).toLong,
maxMessageSize = props.getProperty(MaxMessageBytesProp).toInt,
indexInterval = props.getProperty(IndexIntervalBytesProp).toInt,
fileDeleteDelayMs = props.getProperty(FileDeleteDelayMsProp).toInt,
... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "Lice... | fim | yahoo/CMAK | scala |
<|fim_suffix|>TopicIdentity: TopicIdentity): Try[TopicIdentity] = {
Try {
val assignedReplicas = adminUtils.assignReplicasToBrokers(
brokerList,
currentTopicIdentity.partitions,
currentTopicIdentity.replicationFactor)
val newTpi: Map[Int, TopicPartitionIdentity] = currentTopicIde... | fim | yahoo/CMAK | scala |
<|fim_suffix|>Path(curator, ZkUtils.SchedulePreferredLeaderElectionPath, jsonData)
logger.info("Updating ZK scheduler with %s".format(jsonData))
}
}
<|fim_prefix|>/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "Lice... | fim | yahoo/CMAK | scala |
<|fim_suffix|>nableDoc)
.define(MinInSyncReplicasProp, INT, Defaults.MinInSyncReplicas, atLeast(1), MEDIUM, MinInSyncReplicasDoc)
.define(CompressionTypeProp, STRING, Defaults.CompressionType, in(BrokerCompressionCodec.brokerCompressionOptions:_*), MEDIUM, CompressionTypeDoc)
.define(PreAllocateEnable... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package loader
import controllers.{AssetsComponents, BasicAuthenticationFilter, KafkaManagerContext}
import features.ApplicationFeatures
import models.navigation.Menus
import play.api.{A... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE fil<|fim_suffix|>, url: String)
<|fim_middle|>e.
*/
package models
/**
* @author hiral
*/
case class FollowLink(title: String<|endoftext|> | fim | yahoo/CMAK | scala |
<|fim_suffix|>st[BConfig], readVersion: Int) extends BrokerOperation
<|fim_prefix|>/**
* Copyright 2015 Y<|fim_middle|>ahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package models.form
/**
* @author liu qiang
*/
sealed trait BrokerOperation
case class BConfig(nam... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package models.form
import kafka.manager.model.{ClusterConfig, ClusterTuning, SASLmechanism, SecurityProtocol}
/**
* @author hiral
*/
sealed trait Operation
case object Enable extends... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package models.form
/**
* @author hiral
*/
sealed trait LogkafkaOperation
case class LKConfig(name: String, value: Option[String])
case class CreateLogkafka(logkafka_id: String, log... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package models.form
/**
* @author hiral
*/
sealed trait PreferredReplicaElectionOperation
case object RunElection extends PreferredReplicaElectionOperation
case class UnknownPREO(op: ... | fim | yahoo/CMAK | scala |
/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package models.form
import enumeratum.{Enum, EnumEntry}
import enumeratum.EnumEntry.{Uppercase, Snakecase}
import kafka.manager.model.ActorModel
import ActorModel.BrokerIdentity
/**
* @author hiral
... | fim | yahoo/CMAK | scala |
<|fim_suffix|>dVersion]) extends TopicOperation
case class UpdateTopicConfig(topic: String, configs: List[TConfig], readVersion: Int) extends TopicOperation
case class UnknownTO(op: String) extends TopicOperation
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See acc<|... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package models.navigation
import play.api.mvc.Call
/**
* @author hiral
*/
object BreadCrumbs {
sealed trait BreadCrumb
final case class BCDynamicText(cn: String => String) extend... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyrigh<|fim_suffix|>, items:Seq[(String,Call)], route : Option[Call]) {
require(items.nonEmpty && route.isEmpty || items.isEmpty && route.isDefined, "Cannot have both menu items and a root link")
}
<|fim_middle|>t 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanyin... | fim | yahoo/CMAK | scala |
<|fim_suffix|>ster: String)
(implicit clusterFeatures: ClusterFeatures) : IndexedSeq[Menu] = {
IndexedSeq(
clusterMenu(cluster),
brokersMenu(cluster),
topicMenu(cluster),
preferredReplicaElectionMenu(cluster),
scheduleLeaderElectionMenu(cluster),
reassignPartiti... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package models.navigation
import play.api.mvc.Call
/**
* @author hiral
*/
object QuickRoutes {
import models.navigation.BreadCrumbs._
val baseRoutes : Map[String, () => Call] = M... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package org.apache.kafka.common.metrics
import java.util
import grizzled.<|fim_suffix|>
override def close(): Unit = {}
override def configure(configs: util.Map[String, _]): Unit =... | fim | yahoo/CMAK | scala |
<|fim_suffix|>ta-dt-idx': counter,
'tabindex': settings.iTabIndex,
'class': 'page-link'
} )
.html( btnDisplay )
)
.appendTo( container );
settings.oApi._fnBindAction(
node, {action: button}, clickHandler
);
counter++;
}
}
}
};
// IE9 throws an... | fim | yahoo/CMAK | javascript |
<|fim_prefix|>/*!
DataTables 1.10.18
©2008-2018 SpryMedia Ltd - datatables.net/license
*/
(function(h){"function"===typeof define&&define.amd?define(["jquery"],function(E){return h(E,window,document)}):"object"===typeof exports?module.exports=function(E,H){E||(E=window);H||(H="undefined"!==typeof window?require("jque... | fim | yahoo/CMAK | javascript |
<|fim_suffix|>kafkaStateCheck.get.groupSummaryAction("non-existent", "weird", "KF").apply(FakeRequest())
assert(status(future) === BAD_REQUEST)
}
test("get clusters") {
val future = kafkaStateCheck.get.clusters.apply(FakeRequest())
assert(status(future) === OK)
val json = Json.parse(contentAsJson(f... | fim | yahoo/CMAK | scala |
<|fim_suffix|>QueueSize)
,Option(defaultPoolSize)
,Option(defaultPoolQueueSize)
,Option(defaultGroupMemberMetadataCheckMillis)
,Option(defaultGroupTopicPartitionOffsetMaxSize)
,Option(defaultGroupTopicPartitionOffsetExpireDays)
)
}
}
<|fim_prefix|>package kafka.manager
import kafka.... | fim | yahoo/CMAK | scala |
/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package kafka.manager
import java.util.Properties
import java.util.concurrent.TimeUnit
import akka.actor.{ActorRef, ActorSystem, Kill, Props}
import akka.pattern._
import akka.util.Timeout
import com.... | fim | yahoo/CMAK | scala |
<|fim_suffix|>tLogkafkaLogkafkaIds) { result: LogkafkaLogkafkaIdList =>
assert(result.list.contains(createLogkafkaLogkafkaId),"Failed to create logkafka")
}
withClusterManagerActor(CMGetLogkafkaIdentity(createLogkafkaLogkafkaId)) { result: Option[CMLogkafkaIdentity] =>
assert(result.get.logkafkaIde... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package kafka.manager
import java.util.Properties
import java.util.concurrent.atomic.AtomicBoolean
import akka.actor.Cancellable
import com.typesafe.config.{Config, ConfigFactory}
import... | fim | yahoo/CMAK | scala |
<|fim_suffix|>erZkPath, jmxEnabled = false, pollConsumers = true, filterConsumers = true, logkafkaEnabled = true, jmxUser = None, jmxPass = None, jmxSsl = false, tuning = Option(defaultTuning), securityProtocol="PLAINTEXT", saslMechanism = None, jaasConfig = None)
withKafkaManagerActor(KMUpdateCluster(cc2)) { resul... | fim | yahoo/CMAK | scala |
<|fim_suffix|>trics.getObjectName(Kafka_1_1_1,"MessagesInPerSec",Some("topic"))
assert(on.getCanonicalName === """kafka.server:name=MessagesInPerSec,topic=topic,type=BrokerTopicMetrics""")
}
}
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE... | fim | yahoo/CMAK | scala |
<|fim_suffix|>get topic config") {
withKafkaStateActor(KSGetTopics) { result: TopicList =>
val configs = result.list map { topic =>
withKafkaStateActor(KSGetTopicConfig(topic)) { topicConfig: TopicConfig => topicConfig }
}
configs foreach println
}
}
test("get broker list") {
... | fim | yahoo/CMAK | scala |
<|fim_suffix|>fig, ClusterContext}
import kafka.manager.utils.KafkaServerInTest
import ActorModel._
import kafka.test.SeededBroker
import scala.concurrent.Await
import scala.concurrent.duration._
import scala.reflect.ClassTag
import scala.util.Try
/**
* @author hiral
*/
class TestLogkafkaStateActor extends KafkaSer... | fim | yahoo/CMAK | scala |
<|fim_suffix|>f[KafkaStateActor],sharedCurator, defaultClusterContext)
logkafkaStateActor = Some(system.actorOf(props.withDispatcher("pinned-dispatcher"),"lksa"))
val lkvConfig = LogkafkaViewCacheActorConfig(logkafkaStateActor.get.path, clusterContext, LongRunningPoolConfig(2,100), FiniteDuration(10, SECONDS)... | fim | yahoo/CMAK | scala |
<|fim_suffix|>","endpoints":["PLAINTEXT://host.com:9092", "SASL_PLAINTEXT://host.com:9093"],"host":"host.com","version":2,"port":9092}"""
val biVal = BrokerIdentity.from(1, jsonString)
assert(biVal.isSuccess)
val bi = biVal.toOption.get
assert(bi.host === "host.com")
assert(bi.endpoints.contains(PL... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyright 2017 Yahoo Inc. Licensed under the Apache License, Version<|fim_suffix|>) {
kafkaVersionMap.foreach(v => assertResult(v._2)(KafkaVersion(v._1)))
}
test("apply method: Not supported version.") {
val expected: String = "0.7.0.0"
intercept[IllegalArgumentException] {
K... | fim | yahoo/CMAK | scala |
/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package kafka.manager.utils
import org.apache.curator.framework.{CuratorFrameworkFactory, CuratorFramework}
import org.apache.curator.retry.ExponentialBackoffRetry
import org.apache.curator.test.Testin... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package kafka.manager.utils
import kafka.manager.model.CuratorConfig
import org.apache.curator.framework.{CuratorFrameworkFactory, CuratorFramework}
import org.apache.curator.retry.Bounde... | fim | yahoo/CMAK | scala |
<|fim_suffix|>("blah"))
val serialize: String = ClusterConfig.serialize(cc)
val deserialize = ClusterConfig.deserialize(serialize)
assert(deserialize.isSuccess === true)
assert(cc == deserialize.get)
}
test("serialize and deserialize 2.2.2") {
val cc = ClusterConfig("qa", "2.2.2", "localhost:... | fim | yahoo/CMAK | scala |
<|fim_suffix|> }
}
test("create logkafka with log path too long") {
val config = new Properties()
config.put(kafka.manager.utils.logkafka82.LogConfig.TopicProp, createLogkafkaTopic)
checkError[InvalidLogPathLength] {
withCurator { curator =>
adminUtils.createLogkafka(curator, createLog... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package kafka.manager.utils
import java.util.Properties
import TopicErrors._
import kafka.manager.BaseTest
import kafka.manager.model.ActorModel
import ActorModel.{PartitionOffsetsCaptur... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompanying LICENSE file.
*/
package kafka.manager.utils
import kafka.manager.utils.zero81.{PreferredLeaderElectionErrors, PreferredReplicaLeaderElectionCommand}
import org.apache.kafka.common.TopicPartition
/**
* ... | fim | yahoo/CMAK | scala |
<|fim_suffix|>{ case (t,td) =>
(t,reassignPartitionCommand.generateAssignment(
brokerList,
td.copy(partitionsIdentity = td.partitionsIdentity.map { case (p,l) => (p, l.copy(replicas = l.replicas.drop(1)))})).get)
}
reassignPartitionCommand.executeAssignment(curator,cur... | fim | yahoo/CMAK | scala |
<|fim_prefix|>/**
* Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
* See accompany<|fim_suffix|>rver()
override protected def beforeAll(): Unit = {
super.beforeAll()
testServer.start()
}
override protected def afterAll(): Unit = {
testServer.stop()
super.afterAll()
... | fim | yahoo/CMAK | scala |
<|fim_suffix|>onsumersPath = "/consumers"
val ClusterIdPath = s"$ClusterPath/id"
val BrokerIdsPath = s"$BrokersPath/ids"
val BrokerTopicsPath = s"$BrokersPath/topics"
val ReassignPartitionsPath = s"$AdminPath/reassign_partitions"
val DeleteTopicsPath = s"$AdminPath/delete_topics"
val PreferredReplicaLeaderE... | fim | yahoo/CMAK | scala |
<|fim_suffix|>sList(topic))
info("setup:complete topic=%s for zk=%s and groupId=%s".format(topic,brokerConnect,groupId))
def read(write: (String)=>Unit) = {
import collection.JavaConverters._
while (true) {
val records : ConsumerRecords[String, String] = consumer.poll(Duration.ofMillis(pollMillis))
... | fim | yahoo/CMAK | scala |
package loader
import controllers.{ApiHealth, KafkaManagerContext}
import controllers.api.KafkaStateCheck
import features.ApplicationFeatures
import models.navigation.Menus
import play.api.ApplicationLoader.Context
import play.api.{Application, ApplicationLoader, LoggerConfigurator}
import scala.concurrent.ExecutionC... | fim | yahoo/CMAK | scala |
<|fim_prefix|># inclu<|fim_suffix|>n 0;
}
<|fim_middle|>de <stdio.h>
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
int main(int argc, char *argv[])
{
int n;
n = atoi (argv[1]);
if (likely(n == 10)){
n = n + 2;
} else {
n = n - 2;
}
printf("%d\n", n);
retur... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_prefix|># include <stdio.h>
#define likely(x) __builtin_expect(!!(x), <|fim_suffix|> int n;
n = atoi (argv[1]);
if (unlikely(n == 10)){
n = n + 2;
} else {
n = n - 2;
}
printf("%d\n", n);
return 0;
}
<|fim_middle|>1)
#define unlikely(x) __builtin_expect(!!(x), 0)
int main(int argc, char *argv[])
... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_suffix|>ar c;
int in;
int i;
in = open("in.txt", O_RDONLY);
for(i=0; i<100; i++){
read(in,&c,1);
}
return 0;
} <|fim_prefix|>#include <<|fim_middle|>fcntl.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
ch<|endoftext|> | fim | yanfeizhang/coder-kung-fu | c |
<|fim_prefix|>#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
#include <sched.h>
#include <sys/types.h>
#include <unistd.h> //pipe()
int main()
{
int x, i, fd[2], p[2];
<|fim_suffix|> }
else {
sched_setscheduler(getpid(), SCHED_FIFO, &par... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_prefix|>package main
import (
"fmt"
"time"
"runtime"
)
func cal() {
for i :=0 ; i<1000000 ;i++{
//fmt.Printf("call:%d\n",i)
runtime.Gosched()
}
}
func main() {
runtime.GOMAXPROCS(1)
curr<|fim_suffix|>Time)
go cal()
for i :=0 ; i<1000000 ;i++{
//fmt.Printf("main:%d\n",i)
runtime.Gosched()
}... | fim | yanfeizhang/coder-kung-fu | go |
<|fim_suffix|> main()
{
inti();
printf("%6.6f\n",self_test());
printf("%6.6f\n",threading_test());
distroy();
exit(0);
}<|fim_prefix|>#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <pthread.h>
int pipes[20][3];
char buffer[10];
int running = 1;
void inti()
{
int i =20;
while(i--)
{
if... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_suffix|>perf_event_open系统调用
int perf_event_open(struct perf_event_attr *attr, pid_t pid, int cpu, int group_fd, unsigned long flags)
{
return syscall(__NR_perf_event_open, attr,pid, cpu, group_fd, flags);
}
int main()
{
// 第一步:创建perf文件描述符
// 准备参数
struct perf_event_attr attr;
memset(&attr,0,s... | fim | yanfeizhang/coder-kung-fu | c |
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void caculate(){
for (i = 0; i < 10000000; i++) {
}
}
void funcE(){
caculate();
}
void funcD(){
funcE();
}
void funcA(){
funcD();
}
void funcB(){
caculate();
}
void funcC(){
caculate();
}
int main() {
int i;
for (i = 0; ... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_suffix|>(2,3);
printf("C调用Go函数2+3=%d", ret);
return 0;
}<|fim_prefix|>#include <std<|fim_middle|>io.h>
#include "libadd.h"
int main(void)
{
int ret = add<|endoftext|> | fim | yanfeizhang/coder-kung-fu | c |
<|fim_prefix|>package main
/<|fim_suffix|>func main() {
}
<|fim_middle|>/int add(int a, int b);
import "C"
//export add
func add(a, b C.int) C.int {
return a + b
}
<|endoftext|> | fim | yanfeizhang/coder-kung-fu | go |
<|fim_prefix|>#include <stdio.h>
#include <stdlib.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
#include <sys/reg.h>
void handle_syscall(pid_t pid) {
long syscall_number;
char *syscall_name = NULL;
// 读取系统调用号
... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_suffix|>n $result;
}
public function runFioTest($section){
$cmd = "fio ".$this->_in." --section=".$section." --output-format=json";
echo $cmd."\n";
$result = shell_exec($cmd);
return $result;
}
public function getSections($fioFile){
$matches = array();
$contents = file_get_contents($fioFile);
... | fim | yanfeizhang/coder-kung-fu | php |
<|fim_prefix|><<|fim_suffix|>h($sections as $sec){
$fioResult = $this->runFioTest($sec);
file_put_contents("data/".$sec, $fioResult);
$res = $this->parseFioResult($fioResult);
$line = $sec."\t".$res['bw']."\t".$res['lat']."\t".$res['iops']."\n";
echo $line;
file_put_contents($this->_out, $line, F... | fim | yanfeizhang/coder-kung-fu | php |
<|fim_prefix|><?php
class FioTest {
private $_in = "read.fio";
private $_out = "data/read_total";
public function run(){
file_put_contents($this->_out, "");
$sections = $this->getSections($this->_in);
foreach($sections as $sec){
$fioResult = $this->runFioTest($sec);
file_put_contents("data/".$sec... | fim | yanfeizhang/coder-kung-fu | php |
<?php
class FioTest {
private $_in = "write.fio";
private $_out = "data/write_total";
public function run(){
file_put_contents($this->_out, "");
$sections = $this->getSections($this->_in);
foreach($sections as $sec){
$fioResult = $this->runFioTest($sec);
file_put_contents("data/".$sec, $fioResult... | fim | yanfeizhang/coder-kung-fu | php |
#include <stdio.h>
#include <stdlib.h>
#include <bpf/libbpf.h>
#include "hello_kprobe.skel.h"
static int libbpf_print_fn(enum libbpf_print_level level, const char *format, va_list args) {
return vfprintf(stderr, format, args);
}
int main(int argc, char **argv) {
struct hello_kprobe_bpf *skel;
int err;
... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_prefix|>#include <linux/bpf.h>
#include <bpf/bpf_help<|fim_suffix|>_printk("Hello, World from kprobe!\n");
return 0;
}
char _license[] SEC("license") = "GPL";
<|fim_middle|>ers.h>
// 定义一个打印信息的函数
SEC("kprobe/handle_mm_fault")
int bpf_probe_handle_mm_fault() {
// 打印一条消息到内核调试日志
bpf<|endoftext|> | fim | yanfeizhang/coder-kung-fu | c |
<|fim_suffix|>0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\0\0\0\x01\
\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x8f\0\0\0\0\0\0\0\xaf\0\0\0\0\0\0\0\0\0\
\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x88\0\0\0\x01\0\0\0\0\0\0\0\0\0\
\0\0\0\0\0\0\0\0\0\0\x3e\x01\0\0\0\0\0\0\xe5\0\0\0\0\0\0\0\0\0\0\0\... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_prefix|>#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/times.h>
#include "clock.h"
#include <time.h>
/* Routines for using cycle counter */
/* Detect whether running <|fim_suffix|>ec-time1.tv_sec)*1000000000 + (time2.tv_nsec-time1.tv_nsec);
return usedMircoSecond;
}
double ovhd()
{
... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_suffix|>cycles since counter started */
double get_counter();
void start_timer();
long int get_timer();
/* Measure overhead for counter */
double ovhd();
/* Determine clock rate of processor */
double mhz(int verbose);
/* Determine clock rate of processor, having more control over accuracy */
double mhz_ful... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_prefix|>#include <stdlib.h>
#include <stdio.h>
#include "clock.h"
#define MINBYTES (1 << 11) // 内存测试区域从 2KB 开始
#define MAXBYTES (1 << 26) // 最大到 64 MB
#define MAXSTRIDE 64 // 循环步长从 1 到 64 字节
#define MAXELEMS MAXBYTES/sizeof(double)
double data[MAXELEMS]; // 测试用的全局内存数组
void init_data(double *da... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_suffix|>uct timespec time1 = {0, 0};
void start_timer()
{
clock_gettime(CLOCK_REALTIME, &time1);
}
long int get_timer()
{
struct timespec time2 = {0, 0};
clock_gettime(CLOCK_REALTIME, &time2);
long int usedMircoSecond = (time2.tv_sec-time1.tv_sec)*1000000000 + (time2.tv_nsec-time1.tv_nsec);
r... | fim | yanfeizhang/coder-kung-fu | c |
/* Routines for using cycle counter */
/* Start the counter */
void start_counter();
/* Get # cycles since counter started */
double get_counter();
void start_timer();
long int get_timer();
/* Measure overhead for counter */
double ovhd();
/* Determine clock rate of processor */
double mhz(int verbose);
/* Dete... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_prefix|>#include <stdlib.h>
#include <stdio.h>
#include "clock.h"
#define MINBYTES (1 << 11) // 内存测试区域从 2KB 开始
#define MAXBYTES (1 << 26) // 最大到 64 MB
#define MAXSTRIDE 64 // 循环步长从 1 到 64 字节
#define MAXELEMS MAXBYTES/sizeof(double)
double data[MAXELEMS]; // 测试用的全局内存数组
void init_data(double *da... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_prefix|><?php
/**
* Socket客户端
*/
if(!isset($argv[1]) || !isset($argv[2]) || !isset($argv[3])){
echo "usage: php client.php {localIp} {serverIp} {serverPort} \n";
exit;
}
$localIp = $argv[1];
$serverIp = $argv[2];
$serverPort = $argv[3];
$sockets = array();
function buildConnect($l... | fim | yanfeizhang/coder-kung-fu | php |
<|fim_suffix|>se";
}
}
switch($argv[1]){
case "ping":
foreach($ips as $k=>$ip){
echo $ip.":".pingAddress($ip)."\n";
}
break;
case "ifup":
foreach($ips as $k=>$ip){
shell_exec("ifconfig eth0:$k $ip netmask ".$netmask." up");
}
... | fim | yanfeizhang/coder-kung-fu | php |
<|fim_prefix|><?php
/**
* Socket服务端
*/
ini_set('memory_limit','512M')
set_time_limit(0);
if(!isset($argv[1]) || !isset($argv[2])){
echo "usage: php server.php {ip} {port}\n";
exit;
}
$ip = $argv[1];
$port = $argv[2];
if(($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) {
echo "socket_create() 失败的... | fim | yanfeizhang/coder-kung-fu | php |
<|fim_prefix|>#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#define MAX_CONNECTION_NUM 50000
int buildConnect(const char *lIp, const char *sIp, int sPort)
{
int skFd;
if((skFd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_prefix|>#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_CONNECTION_NUM 1100000
int main(int argc, char *argv[])
{
char ip[16];
int lisFd, conFd, port;
struct sockaddr_in servAddr;
if(argc != 3)
{
printf("\n Usage: %s <server ip> <server... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_prefix|>import java.net.Socket;
import java.net.InetSocketAddress;
public class Client {
public static final int MAX_CONNECTION_NUM = 50000;
public static void main(String[] args) throws Exception {
if(3 != args.length){
System.out.println("Usage: java Client <local ip> <server... | fim | yanfeizhang/coder-kung-fu | java |
<|fim_prefix|>import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.InetSocketAddress;
public class Server {
public static final int MAX_CONNECTION_NUM = 1100000;
public static void main(String[] args) {
if(2 != args.length){
System.out.println(... | fim | yanfeizhang/coder-kung-fu | java |
<|fim_suffix|>_last_error($socket))."\n";
sleep(5);
continue;
}
//将 socket 保存起来,避免连接被内核释放
$sockets[] = $socket;
//发送数据
//$wmsg = "I am client\n";
//socket_write($con, $wmsg, strlen($wmsg));
//接收数据
//$rmsg = socket_read($socket, 2... | fim | yanfeizhang/coder-kung-fu | php |
<|fim_suffix|>cket_strerror($sock) . "\n";
exit();
}
if(($ret = socket_bind($sock, $ip, $port)) < 0) {
echo "socket_bind() 失败的原因是:" . socket_strerror($ret) . "\n";
exit();
}
if(($ret = socket_listen($sock,1024)) < 0) {
echo "socket_listen() 失败的原因是:" . socket_strerror($ret) . "\n";
exit();
}
echo "... | fim | yanfeizhang/coder-kung-fu | php |
<|fim_suffix|>sPort, i);
sleep(1);
}
fd = buildConnect(sIp, sPort);
if(fd > 0)
{
sockets[i-1] = fd;
}else{
return 1;
}
}
sleep(300);
//3. 释放所有的连接
printf("关闭所有的连接...\n");
for(i = 0; i < MAX_CONNECTION_NUM; i... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_prefix|>#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_CONNECTION_NUM 1100000
int main(int argc, char *argv[])
{
char ip[16];
int lisFd, conFd, port;
struct sockaddr_in servAddr;
if(argc != 3)
{
printf("\n Usage: %s <server ip> <server... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_suffix|>intln("连接 "+sIp+":"+sPort+" 成功了 "+i+" 条");
}
}
//把所有连接都 hold 一会儿,方便观察
Thread.sleep(300 * 1000);
//3. 释放所有的连接
System.out.println("关闭所有的连接...\n");
for(int i = 0; i < MAX_CONNECTION_NUM; i++){
sockets[i].close();
}
}
}... | fim | yanfeizhang/coder-kung-fu | java |
<|fim_prefix|>import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.InetSocketAddress;
public class<|fim_suffix|>ort = Integer.parseInt(args[1]);
//用数组将 socket 保存起来,防止连接被过早回收
Socket[] sockets = new Socket[MAX_CONNECTION_NUM];
try {
Serv... | fim | yanfeizhang/coder-kung-fu | java |
<|fim_suffix|>
}
}
echo "\nconnect start:";
buildConnect($serverIp, $serverPort, 50000);
sleep(600);
echo "\nclose all sockets now";
closeAll();
<|fim_prefix|><?php
/**
* Socket客户端
*/
if(!isset($argv[1]) || !isset($argv<|fim_middle|>[2])){
echo "usage: php client.php {serverIp} {serverPort} \n";
exi... | fim | yanfeizhang/coder-kung-fu | php |
<|fim_suffix|>et_last_error($socket))."\n";
continue;
} else {
echo "$ip $port accept success: ".$count++."\n";
//发送数据
//$wmsg = "I am server\n";
//socket_write($con, $wmsg, strlen($wmsg));
//接收数据
//$rmsg = socket_read($msgsock[$count], 2048);
//echo... | fim | yanfeizhang/coder-kung-fu | php |
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <linux/if_ether.h>
#include <linux/in.h>
#define BUFFER_MAX 2048
typedef int int32;
typedef unsigned int u_int32;
typedef unsigned char u_char;
typedef unsigned short u_short;
//参考内核 struct ethhdr 定义 (i... | fim | yanfeizhang/coder-kung-fu | c |
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#define MAX_CONNECTION_NUM 100
int buildConnect(const char *sIp, int sPort)
{
int skFd;
if((skFd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
printf("\n Error : Could not cr... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_prefix|>#include <arpa/i<|fim_suffix|>ORT, &val, sizeof(val))<0)
{
printf("\n Server %d Error : setsockopt failed!\n", pid);
return 0;
}
//2.3 bind绑定
servAddr.sin_family = AF_INET;
servAddr.sin_addr.s_addr = inet_addr(ip);
servAddr.sin_port = htons(port);
if... | fim | yanfeizhang/coder-kung-fu | c |
<|fim_prefix|>/// <reference types="next" />
/// <reference types="next/image-types/g<|fim_suffix|>edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
<|fim_middle|>lobal" />
// NOTE: This file should not be <|endoftext|> | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|>e',
},
reactStrictMode: true,
swcMinify: true,
});
<|fim_prefix|>import './src/env/server.mjs';
/**
* Don't be scared of the generics here.
* All they do is to give us autocompletion when using this.
*
* @template {import('next').NextConfig} T
* @param {T} config - A generic parameter that flo... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_suffix|>it prisma.$disconnect();
process.exit(1);
});
export {};
<|fim_prefix|>import { PrismaClient } from '@prisma/client';
import { generateAnalysis } from '../src/utils/offers/analysis/analysisGeneration';
const prisma = new PrismaClient();
const seedAnalysis = async () => {
console.log('Busy crunc... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import * as fs from 'fs';
const { PrismaClient } = require('@prisma/client');
const { parse } = require('csv-parse/sync');
const prisma = new PrismaClient();
async function main() {
console.log('Seeding started...');
const file = fs.readFileSync('prisma/companies.csv');
const companies = parse(fi... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> (!firstCompany) {
throw new Error(
'No company found. Please seed db with some companies first.',
);
}
const firstCity = await prisma.city.findFirst({
include: {
state: true,
},
});
if (!firstCity) {
throw new Error('No city found. Please seed db with some cities ... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_suffix|> 'SGD',
baseCurrencyString,
),
currency: 'SGD',
value: data.Stocks
? typeof data.Stocks === 'number'
? data.Stocks
... | fim | yangshun/tech-interview-handbook | typescript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.