本文整理汇总了C++中Return函数的典型用法代码示例。如果您正苦于以下问题:C++ Return函数的具体用法?C++ Return怎么用?C++ Return使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Return函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_F
// This test ensures that when explicit acknowledgements are enabled,
// acknowledgements for master-generated updates are dropped by the
// driver. We test this by creating an invalid task that uses no
// resources.
TEST_F(MesosSchedulerDriverTest, ExplicitAcknowledgementsMasterGeneratedUpdate)
{
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
Owned<MasterDetector> detector = master.get()->createDetector();
Try<Owned<cluster::Slave>> slave = StartSlave(detector.get());
ASSERT_SOME(slave);
MockScheduler sched;
MesosSchedulerDriver driver(
&sched,
DEFAULT_FRAMEWORK_INFO,
master.get()->pid,
false,
DEFAULT_CREDENTIAL);
EXPECT_CALL(sched, registered(&driver, _, _));
Future<vector<Offer>> offers;
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillOnce(FutureArg<1>(&offers))
.WillRepeatedly(Return()); // Ignore subsequent offers.
// Ensure no status update acknowledgements are sent to the master.
EXPECT_NO_FUTURE_CALLS(
mesos::scheduler::Call(),
mesos::scheduler::Call::ACKNOWLEDGE,
_ ,
master.get()->pid);
driver.start();
AWAIT_READY(offers);
EXPECT_NE(0u, offers->size());
// Launch a task using no resources.
TaskInfo task;
task.set_name("");
task.mutable_task_id()->set_value("1");
task.mutable_slave_id()->MergeFrom(offers.get()[0].slave_id());
task.mutable_executor()->MergeFrom(DEFAULT_EXECUTOR_INFO);
vector<TaskInfo> tasks;
tasks.push_back(task);
Future<TaskStatus> status;
EXPECT_CALL(sched, statusUpdate(&driver, _))
.WillOnce(FutureArg<1>(&status));
driver.launchTasks(offers.get()[0].id(), tasks);
AWAIT_READY(status);
ASSERT_EQ(TASK_ERROR, status->state());
ASSERT_EQ(TaskStatus::SOURCE_MASTER, status->source());
ASSERT_EQ(TaskStatus::REASON_TASK_INVALID, status->reason());
// Now send the acknowledgement.
driver.acknowledgeStatusUpdate(status.get());
// Settle the clock to ensure driver processes the acknowledgement,
// which should get dropped due to having come from the master.
Clock::pause();
Clock::settle();
driver.stop();
driver.join();
}
示例2: POSIXFSAL_close_by_fileid
fsal_status_t POSIXFSAL_close_by_fileid(posixfsal_file_t * file_descriptor /* IN */ ,
fsal_u64_t fileid)
{
Return(ERR_FSAL_NOTSUPP, 0, INDEX_FSAL_open_by_fileid);
}
示例3: SNMPFSAL_getattrs
/**
* FSAL_getattrs:
* Get attributes for the object specified by its filehandle.
*
* \param filehandle (input):
* The handle of the object to get parameters.
* \param p_context (input):
* Authentication context for the operation (user, export...).
* \param object_attributes (mandatory input/output):
* The retrieved attributes for the object.
* As input, it defines the attributes that the caller
* wants to retrieve (by positioning flags into this structure)
* and the output is built considering this input
* (it fills the structure according to the flags it contains).
*
* \return Major error codes :
* - ERR_FSAL_NO_ERROR (no error)
* - ERR_FSAL_STALE (object_handle does not address an existing object)
* - ERR_FSAL_FAULT (a NULL pointer was passed as mandatory argument)
* - Another error code if an error occured.
*/
fsal_status_t SNMPFSAL_getattrs(fsal_handle_t * file_hdl, /* IN */
fsal_op_context_t * context, /* IN */
fsal_attrib_list_t * object_attributes /* IN/OUT */
)
{
int rc;
fsal_status_t status;
fsal_request_desc_t query_desc;
struct tree *mib_node;
netsnmp_variable_list *p_convert_var = NULL;
snmpfsal_handle_t * filehandle = (snmpfsal_handle_t *)file_hdl;
snmpfsal_op_context_t * p_context = (snmpfsal_op_context_t *)context;
/* sanity checks.
* note : object_attributes is mandatory in FSAL_getattrs.
*/
if(!filehandle || !p_context || !object_attributes)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_getattrs);
/* don't call GET request on directory */
if(filehandle->data.object_type_reminder == FSAL_NODETYPE_LEAF && filehandle->data.oid_len != 0)
{
query_desc.request_type = SNMP_MSG_GET;
TakeTokenFSCall();
/* call to snmpget */
rc = IssueSNMPQuery(p_context, filehandle->data.oid_tab, filehandle->data.oid_len,
&query_desc);
ReleaseTokenFSCall();
/* convert error code in case of error */
if(rc != SNMPERR_SUCCESS && snmp2fsal_error(rc) != ERR_FSAL_NOENT)
Return(snmp2fsal_error(rc), rc, INDEX_FSAL_getattrs);
if(snmp2fsal_error(rc) == ERR_FSAL_NOENT)
Return(ERR_FSAL_STALE, rc, INDEX_FSAL_getattrs);
p_convert_var = p_context->snmp_response->variables;
/* check no such object, etc... */
if(p_convert_var->type == SNMP_NOSUCHOBJECT
|| p_convert_var->type == SNMP_NOSUCHINSTANCE
|| p_convert_var->type == SNMP_ENDOFMIBVIEW)
Return(ERR_FSAL_STALE, p_convert_var->type, INDEX_FSAL_getattrs);
/* retrieve the associated MIB node (can be null) */
mib_node = GetMIBNode(p_context, filehandle, TRUE);
} /* endif not root */
else if(filehandle->data.object_type_reminder != FSAL_NODETYPE_ROOT
&& filehandle->data.oid_len != 0)
{
/* retrieve the associated MIB node (can be null) */
mib_node = GetMIBNode(p_context, filehandle, TRUE);
}
else /* root */
mib_node = NULL;
/* @todo check no such object, etc... */
/* convert SNMP attributes to FSAL attributes */
rc = snmp2fsal_attributes(filehandle, p_convert_var, mib_node, object_attributes);
Return(rc, 0, INDEX_FSAL_getattrs);
}
示例4: POSIXFSAL_open
/**
* FSAL_open:
* Open a regular file for reading/writing its data content.
*
* \param filehandle (input):
* Handle of the file to be read/modified.
* \param cred (input):
* Authentication context for the operation (user,...).
* \param openflags (input):
* Flags that indicates behavior for file opening and access.
* This is an inclusive OR of the following values
* ( such of them are not compatible) :
* - FSAL_O_RDONLY: opening file for reading only.
* - FSAL_O_RDWR: opening file for reading and writing.
* - FSAL_O_WRONLY: opening file for writting only.
* - FSAL_O_APPEND: always write at the end of the file.
* - FSAL_O_TRUNC: truncate the file to 0 on opening.
* \param file_descriptor (output):
* The file descriptor to be used for FSAL_read/write operations.
* \param file_attributes (optionnal input/output):
* Post operation attributes.
* As input, it defines the attributes that the caller
* wants to retrieve (by positioning flags into this structure)
* and the output is built considering this input
* (it fills the structure according to the flags it contains).
*
* \return Major error codes:
* - ERR_FSAL_NO_ERROR: no error.
* - Another error code if an error occured during this call.
*/
fsal_status_t POSIXFSAL_open(posixfsal_handle_t * p_filehandle, /* IN */
posixfsal_op_context_t * p_context, /* IN */
fsal_openflags_t openflags, /* IN */
posixfsal_file_t * p_file_descriptor, /* OUT */
fsal_attrib_list_t * p_file_attributes /* [ IN/OUT ] */
)
{
int rc, errsv;
fsal_status_t status;
fsal_path_t fsalpath;
struct stat buffstat;
#ifdef _FSAL_POSIX_USE_STREAM
char posix_flags[4]; /* stores r, r+, w, w+, a, or a+ */
#else
int posix_flags;
#endif
/* sanity checks.
* note : file_attributes is optional.
*/
if(!p_filehandle || !p_context || !p_file_descriptor)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_open);
status =
fsal_internal_getPathFromHandle(p_context, p_filehandle, 0, &fsalpath, &buffstat);
if(FSAL_IS_ERROR(status))
Return(status.major, status.minor, INDEX_FSAL_open);
status =
fsal_internal_testAccess(p_context,
(openflags & FSAL_O_RDONLY ? FSAL_R_OK : FSAL_W_OK) |
FSAL_OWNER_OK, &buffstat, NULL);
if(FSAL_IS_ERROR(status))
Return(status.major, status.minor, INDEX_FSAL_open);
/* convert fsal open flags to posix open flags */
rc = fsal2posix_openflags(openflags, &posix_flags);
/* flags conflicts. */
if(rc)
{
LogEvent(COMPONENT_FSAL, "Invalid/conflicting flags : %#X", openflags);
Return(rc, 0, INDEX_FSAL_open);
}
TakeTokenFSCall();
#ifdef _FSAL_POSIX_USE_STREAM
p_file_descriptor->p_file = fopen(fsalpath.path, posix_flags);
errsv = errno;
ReleaseTokenFSCall();
if(!(p_file_descriptor->p_file))
Return(posix2fsal_error(errsv), errsv, INDEX_FSAL_open);
#else
p_file_descriptor->filefd = open(fsalpath.path, posix_flags);
errsv = errno;
ReleaseTokenFSCall();
#endif
/* set the read-only flag of the file descriptor */
p_file_descriptor->ro = openflags & FSAL_O_RDONLY;
/* output attributes */
if(p_file_attributes)
{
status = posix2fsal_attributes(&buffstat, p_file_attributes);
//.........这里部分代码省略.........
示例5: POSIXFSAL_write
fsal_status_t POSIXFSAL_write(posixfsal_file_t * p_file_descriptor, /* IN */
fsal_seek_t * p_seek_descriptor, /* IN */
fsal_size_t buffer_size, /* IN */
caddr_t buffer, /* IN */
fsal_size_t * p_write_amount /* OUT */
)
{
size_t nb_written;
size_t i_size;
int rc, errsv;
/* sanity checks. */
if(!p_file_descriptor || !buffer || !p_write_amount)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_write);
if(p_file_descriptor->ro)
Return(ERR_FSAL_PERM, 0, INDEX_FSAL_write);
/** @todo: manage fsal_size_t to size_t convertion */
i_size = (size_t) buffer_size;
/* positioning */
if(p_seek_descriptor)
{
switch (p_seek_descriptor->whence)
{
case FSAL_SEEK_CUR:
/* set position plus offset */
TakeTokenFSCall();
rc = fseek(p_file_descriptor->p_file, p_seek_descriptor->offset, SEEK_CUR);
errsv = errno;
ReleaseTokenFSCall();
break;
case FSAL_SEEK_SET:
/* set absolute position to offset */
TakeTokenFSCall();
rc = fseek(p_file_descriptor->p_file, p_seek_descriptor->offset, SEEK_SET);
errsv = errno;
ReleaseTokenFSCall();
break;
case FSAL_SEEK_END:
/* set end of file plus offset */
TakeTokenFSCall();
rc = fseek(p_file_descriptor->p_file, p_seek_descriptor->offset, SEEK_END);
errsv = errno;
ReleaseTokenFSCall();
break;
}
if(rc)
{
LogEvent(COMPONENT_FSAL,
"Error in posix fseek operation (whence=%s, offset=%lld)",
(p_seek_descriptor->whence == FSAL_SEEK_CUR ? "SEEK_CUR" :
(p_seek_descriptor->whence == FSAL_SEEK_SET ? "SEEK_SET" :
(p_seek_descriptor->whence ==
FSAL_SEEK_END ? "SEEK_END" : "ERROR"))),
p_seek_descriptor->offset);
Return(posix2fsal_error(errsv), errsv, INDEX_FSAL_write);
}
LogFullDebug(COMPONENT_FSAL,
"Write operation (whence=%s, offset=%lld, size=%lld)",
(p_seek_descriptor->whence ==
FSAL_SEEK_CUR ? "SEEK_CUR" : (p_seek_descriptor->whence ==
FSAL_SEEK_SET ? "SEEK_SET"
: (p_seek_descriptor->whence ==
FSAL_SEEK_END ? "SEEK_END" :
"ERROR"))),
p_seek_descriptor->offset, buffer_size);
}
/* write operation */
TakeTokenFSCall();
nb_written = fwrite(buffer, 1, i_size, p_file_descriptor->p_file);
/* With no flush, uncommited write may occur on 64 bits platforms */
(void)fflush(p_file_descriptor->p_file);
ReleaseTokenFSCall();
/** @todo: manage ssize_t to fsal_size_t convertion */
if(nb_written <= 0 && ferror(p_file_descriptor->p_file))
//.........这里部分代码省略.........
示例6: TEST_F
// This test verifies that a re-registering slave sends the terminal
// unacknowledged tasks for a terminal executor. This is required
// for the master to correctly reconcile its view with the slave's
// view of tasks. This test drops a terminal update to the master
// and then forces the slave to re-register.
TEST_F(MasterSlaveReconciliationTest, SlaveReregisterTerminatedExecutor)
{
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
MockExecutor exec(DEFAULT_EXECUTOR_ID);
TestContainerizer containerizer(&exec);
StandaloneMasterDetector detector(master.get()->pid);
Try<Owned<cluster::Slave>> slave = StartSlave(&detector, &containerizer);
ASSERT_SOME(slave);
MockScheduler sched;
MesosSchedulerDriver driver(
&sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
Future<FrameworkID> frameworkId;
EXPECT_CALL(sched, registered(&driver, _, _))
.WillOnce(FutureArg<1>(&frameworkId));
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillOnce(LaunchTasks(DEFAULT_EXECUTOR_INFO, 1, 1, 512, "*"))
.WillRepeatedly(Return()); // Ignore subsequent offers.
ExecutorDriver* execDriver;
EXPECT_CALL(exec, registered(_, _, _, _))
.WillOnce(SaveArg<0>(&execDriver));
EXPECT_CALL(exec, launchTask(_, _))
.WillOnce(SendStatusUpdateFromTask(TASK_RUNNING));
Future<TaskStatus> status;
EXPECT_CALL(sched, statusUpdate(&driver, _))
.WillOnce(FutureArg<1>(&status));
Future<StatusUpdateAcknowledgementMessage> statusUpdateAcknowledgementMessage
= FUTURE_PROTOBUF(
StatusUpdateAcknowledgementMessage(),
master.get()->pid,
slave.get()->pid);
driver.start();
AWAIT_READY(status);
EXPECT_EQ(TASK_RUNNING, status.get().state());
// Make sure the acknowledgement reaches the slave.
AWAIT_READY(statusUpdateAcknowledgementMessage);
// Drop the TASK_FINISHED status update sent to the master.
Future<StatusUpdateMessage> statusUpdateMessage =
DROP_PROTOBUF(StatusUpdateMessage(), _, master.get()->pid);
Future<ExitedExecutorMessage> executorExitedMessage =
FUTURE_PROTOBUF(ExitedExecutorMessage(), _, _);
TaskStatus finishedStatus;
finishedStatus = status.get();
finishedStatus.set_state(TASK_FINISHED);
execDriver->sendStatusUpdate(finishedStatus);
// Ensure the update was sent.
AWAIT_READY(statusUpdateMessage);
EXPECT_CALL(sched, executorLost(&driver, DEFAULT_EXECUTOR_ID, _, _));
// Now kill the executor.
containerizer.destroy(frameworkId.get(), DEFAULT_EXECUTOR_ID);
Future<TaskStatus> status2;
EXPECT_CALL(sched, statusUpdate(&driver, _))
.WillOnce(FutureArg<1>(&status2));
// We drop the 'UpdateFrameworkMessage' from the master to slave to
// stop the status update manager from retrying the update that was
// already sent due to the new master detection.
DROP_PROTOBUFS(UpdateFrameworkMessage(), _, _);
detector.appoint(master.get()->pid);
AWAIT_READY(status2);
EXPECT_EQ(TASK_FINISHED, status2.get().state());
driver.stop();
driver.join();
}
示例7: LUSTREFSAL_readdir
/**
* FSAL_readdir :
* Read the entries of an opened directory.
*
* \param dir_descriptor (input):
* Pointer to the directory descriptor filled by FSAL_opendir.
* \param start_position (input):
* Cookie that indicates the first object to be read during
* this readdir operation.
* This should be :
* - FSAL_READDIR_FROM_BEGINNING for reading the content
* of the directory from the beginning.
* - The end_position parameter returned by the previous
* call to FSAL_readdir.
* \param get_attr_mask (input)
* Specify the set of attributes to be retrieved for directory entries.
* \param buffersize (input)
* The size (in bytes) of the buffer where
* the direntries are to be stored.
* \param pdirent (output)
* Adresse of the buffer where the direntries are to be stored.
* \param end_position (output)
* Cookie that indicates the current position in the directory.
* \param nb_entries (output)
* Pointer to the number of entries read during the call.
* \param end_of_dir (output)
* Pointer to a boolean that indicates if the end of dir
* has been reached during the call.
*
* \return Major error codes :
* - ERR_FSAL_NO_ERROR (no error)
* - Another error code if an error occured.
*/
fsal_status_t LUSTREFSAL_readdir(fsal_dir_t *dir_desc, /* IN */
fsal_cookie_t start_pos, /* IN */
fsal_attrib_mask_t get_attr_mask, /* IN */
fsal_mdsize_t buffersize, /* IN */
fsal_dirent_t * p_pdirent, /* OUT */
fsal_cookie_t * p_end_position, /* OUT */
fsal_count_t * p_nb_entries, /* OUT */
fsal_boolean_t * p_end_of_dir /* OUT */
)
{
fsal_status_t st;
fsal_count_t max_dir_entries;
struct dirent *dp;
struct dirent dpe;
fsal_path_t fsalpath;
int rc;
lustrefsal_dir_t * p_dir_descriptor = (lustrefsal_dir_t *)dir_desc;
lustrefsal_cookie_t start_position;
/*****************/
/* sanity checks */
/*****************/
if(!p_dir_descriptor || !p_pdirent || !p_end_position || !p_nb_entries || !p_end_of_dir)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_readdir);
max_dir_entries = (buffersize / sizeof(fsal_dirent_t));
start_position.data.cookie = (off_t)start_pos.data;
/***************************/
/* seek into the directory */
/***************************/
errno = 0;
if(start_position.data.cookie == 0)
{
rewinddir(p_dir_descriptor->p_dir);
rc = errno;
}
else
{
seekdir(p_dir_descriptor->p_dir, start_position.data.cookie);
rc = errno;
}
if(rc)
Return(posix2fsal_error(rc), rc, INDEX_FSAL_readdir);
/************************/
/* browse the directory */
/************************/
*p_nb_entries = 0;
while(*p_nb_entries < max_dir_entries)
{
/***********************/
/* read the next entry */
/***********************/
TakeTokenFSCall();
rc = readdir_r(p_dir_descriptor->p_dir, &dpe, &dp);
ReleaseTokenFSCall();
if(rc)
{
rc = errno;
Return(posix2fsal_error(rc), rc, INDEX_FSAL_readdir);
}
/* End of directory */
if(!dp)
//.........这里部分代码省略.........
示例8: TEST_F
// The purpose of this test is to ensure that when slaves are removed
// from the master, and then attempt to re-register, we deny the
// re-registration by sending a ShutdownMessage to the slave.
// Why? Because during a network partition, the master will remove a
// partitioned slave, thus sending its tasks to LOST. At this point,
// when the partition is removed, the slave will attempt to
// re-register with its running tasks. We've already notified
// frameworks that these tasks were LOST, so we have to have the slave
// slave shut down.
TEST_F(PartitionTest, PartitionedSlaveReregistration)
{
Try<PID<Master> > master = StartMaster();
ASSERT_SOME(master);
// Allow the master to PING the slave, but drop all PONG messages
// from the slave. Note that we don't match on the master / slave
// PIDs because it's actually the SlaveObserver Process that sends
// the pings.
Future<Message> ping = FUTURE_MESSAGE(Eq("PING"), _, _);
DROP_MESSAGES(Eq("PONG"), _, _);
MockExecutor exec(DEFAULT_EXECUTOR_ID);
StandaloneMasterDetector detector(master.get());
Try<PID<Slave> > slave = StartSlave(&exec, &detector);
ASSERT_SOME(slave);
MockScheduler sched;
MesosSchedulerDriver driver(
&sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
EXPECT_CALL(sched, registered(&driver, _, _));
Future<vector<Offer> > offers;
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillOnce(FutureArg<1>(&offers))
.WillRepeatedly(Return());
driver.start();
AWAIT_READY(offers);
ASSERT_NE(0u, offers.get().size());
// Launch a task. This is to ensure the task is killed by the slave,
// during shutdown.
TaskID taskId;
taskId.set_value("1");
TaskInfo task;
task.set_name("");
task.mutable_task_id()->MergeFrom(taskId);
task.mutable_slave_id()->MergeFrom(offers.get()[0].slave_id());
task.mutable_resources()->MergeFrom(offers.get()[0].resources());
task.mutable_executor()->MergeFrom(DEFAULT_EXECUTOR_INFO);
task.mutable_executor()->mutable_command()->set_value("sleep 60");
vector<TaskInfo> tasks;
tasks.push_back(task);
// Set up the expectations for launching the task.
EXPECT_CALL(exec, registered(_, _, _, _));
EXPECT_CALL(exec, launchTask(_, _))
.WillOnce(SendStatusUpdateFromTask(TASK_RUNNING));
Future<TaskStatus> runningStatus;
EXPECT_CALL(sched, statusUpdate(&driver, _))
.WillOnce(FutureArg<1>(&runningStatus));
Future<Nothing> statusUpdateAck = FUTURE_DISPATCH(
slave.get(), &Slave::_statusUpdateAcknowledgement);
driver.launchTasks(offers.get()[0].id(), tasks);
AWAIT_READY(runningStatus);
EXPECT_EQ(TASK_RUNNING, runningStatus.get().state());
// Wait for the slave to have handled the acknowledgment prior
// to pausing the clock.
AWAIT_READY(statusUpdateAck);
// Drop the first shutdown message from the master (simulated
// partition), allow the second shutdown message to pass when
// the slave re-registers.
Future<ShutdownMessage> shutdownMessage =
DROP_PROTOBUF(ShutdownMessage(), _, slave.get());
Future<TaskStatus> lostStatus;
EXPECT_CALL(sched, statusUpdate(&driver, _))
.WillOnce(FutureArg<1>(&lostStatus));
Future<Nothing> slaveLost;
EXPECT_CALL(sched, slaveLost(&driver, _))
.WillOnce(FutureSatisfy(&slaveLost));
Clock::pause();
// Now, induce a partition of the slave by having the master
// timeout the slave.
uint32_t pings = 0;
//.........这里部分代码省略.........
示例9: TEST_P
TEST_P(MemoryIsolatorTest, ROOT_MemUsage)
{
Try<Owned<cluster::Master>> master = StartMaster();
ASSERT_SOME(master);
slave::Flags flags = CreateSlaveFlags();
flags.isolation = GetParam();
Fetcher fetcher(flags);
Try<MesosContainerizer*> _containerizer =
MesosContainerizer::create(flags, true, &fetcher);
ASSERT_SOME(_containerizer);
Owned<MesosContainerizer> containerizer(_containerizer.get());
Owned<MasterDetector> detector = master.get()->createDetector();
Try<Owned<cluster::Slave>> slave = StartSlave(
detector.get(),
containerizer.get());
ASSERT_SOME(slave);
MockScheduler sched;
MesosSchedulerDriver driver(
&sched,
DEFAULT_FRAMEWORK_INFO,
master.get()->pid,
DEFAULT_CREDENTIAL);
EXPECT_CALL(sched, registered(&driver, _, _));
Future<vector<Offer>> offers;
EXPECT_CALL(sched, resourceOffers(&driver, _))
.WillOnce(FutureArg<1>(&offers))
.WillRepeatedly(Return()); // Ignore subsequent offers.
driver.start();
AWAIT_READY(offers);
ASSERT_FALSE(offers->empty());
TaskInfo task = createTask(offers.get()[0], "sleep 120");
Future<TaskStatus> statusRunning;
EXPECT_CALL(sched, statusUpdate(&driver, _))
.WillOnce(FutureArg<1>(&statusRunning));
driver.launchTasks(offers.get()[0].id(), {task});
AWAIT_READY(statusRunning);
EXPECT_EQ(TASK_RUNNING, statusRunning->state());
Future<hashset<ContainerID>> containers = containerizer->containers();
AWAIT_READY(containers);
ASSERT_EQ(1u, containers->size());
ContainerID containerId = *(containers->begin());
Future<ResourceStatistics> usage = containerizer->usage(containerId);
AWAIT_READY(usage);
// TODO(jieyu): Consider using a program that predictably increases
// RSS so that we can set more meaningful expectation here.
EXPECT_LT(0u, usage->mem_rss_bytes());
driver.stop();
driver.join();
}
示例10: VFSFSAL_truncate
fsal_status_t VFSFSAL_truncate(vfsfsal_handle_t * p_filehandle, /* IN */
vfsfsal_op_context_t * p_context, /* IN */
fsal_size_t length, /* IN */
vfsfsal_file_t * file_descriptor, /* Unused in this FSAL */
fsal_attrib_list_t * p_object_attributes /* [ IN/OUT ] */
)
{
int rc, errsv;
int fd;
fsal_status_t st;
/* sanity checks.
* note : object_attributes is optional.
*/
if(!p_filehandle || !p_context)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_truncate);
/* get the path of the file and its handle */
TakeTokenFSCall();
st = fsal_internal_handle2fd(p_context, p_filehandle, &fd, O_RDWR);
ReleaseTokenFSCall();
if(FSAL_IS_ERROR(st))
ReturnStatus(st, INDEX_FSAL_truncate);
/* Executes the POSIX truncate operation */
TakeTokenFSCall();
rc = ftruncate(fd, length);
errsv = errno;
ReleaseTokenFSCall();
close(fd);
/* convert return code */
if(rc)
{
if(errsv == ENOENT)
Return(ERR_FSAL_STALE, errsv, INDEX_FSAL_truncate);
else
Return(posix2fsal_error(errsv), errsv, INDEX_FSAL_truncate);
}
/* Optionally retrieve attributes */
if(p_object_attributes)
{
fsal_status_t st;
st = VFSFSAL_getattrs(p_filehandle, p_context, p_object_attributes);
if(FSAL_IS_ERROR(st))
{
FSAL_CLEAR_MASK(p_object_attributes->asked_attributes);
FSAL_SET_MASK(p_object_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR);
}
}
/* No error occurred */
Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_truncate);
}
示例11: TEST
TEST(AggregateTests, PlainSumCountDistinctTest) {
/*
* SELECT SUM(a), COUNT(b), COUNT(DISTINCT b) from table
*/
const int tuple_count = TESTS_TUPLES_PER_TILEGROUP;
// Create a table and wrap it in logical tiles
auto &txn_manager = concurrency::TransactionManager::GetInstance();
auto txn = txn_manager.BeginTransaction();
auto txn_id = txn->GetTransactionId();
std::unique_ptr<storage::DataTable> data_table(
ExecutorTestsUtil::CreateTable(tuple_count, false));
ExecutorTestsUtil::PopulateTable(txn, data_table.get(),
2 * tuple_count, false,
true, true);
txn_manager.CommitTransaction();
std::unique_ptr<executor::LogicalTile> source_logical_tile1(
executor::LogicalTileFactory::WrapTileGroup(data_table->GetTileGroup(0),
txn_id));
std::unique_ptr<executor::LogicalTile> source_logical_tile2(
executor::LogicalTileFactory::WrapTileGroup(data_table->GetTileGroup(1),
txn_id));
// (1-5) Setup plan node
// 1) Set up group-by columns
std::vector<oid_t> group_by_columns;
// 2) Set up project info
planner::ProjectInfo::DirectMapList direct_map_list = {
{0, {1, 0}}, {1, {1, 1}}, {2, {1, 2}}};
auto proj_info = new planner::ProjectInfo(planner::ProjectInfo::TargetList(),
std::move(direct_map_list));
// 3) Set up unique aggregates
std::vector<planner::AggregatePlan::AggTerm> agg_terms;
planner::AggregatePlan::AggTerm sumA(EXPRESSION_TYPE_AGGREGATE_SUM,
expression::TupleValueFactory(0, 0),
false);
planner::AggregatePlan::AggTerm countB(EXPRESSION_TYPE_AGGREGATE_COUNT,
expression::TupleValueFactory(0, 1),
false); // Flag distinct
planner::AggregatePlan::AggTerm countDistinctB(
EXPRESSION_TYPE_AGGREGATE_COUNT, expression::TupleValueFactory(0, 1),
true); // Flag distinct
agg_terms.push_back(sumA);
agg_terms.push_back(countB);
agg_terms.push_back(countDistinctB);
// 4) Set up predicate (empty)
expression::AbstractExpression* predicate = nullptr;
// 5) Create output table schema
auto data_table_schema = data_table.get()->GetSchema();
std::vector<oid_t> set = {0, 1, 1};
std::vector<catalog::Column> columns;
for (auto column_index : set) {
columns.push_back(data_table_schema->GetColumn(column_index));
}
auto output_table_schema = new catalog::Schema(columns);
// OK) Create the plan node
planner::AggregatePlan node(proj_info, predicate, std::move(agg_terms),
std::move(group_by_columns), output_table_schema,
AGGREGATE_TYPE_PLAIN);
// Create and set up executor
auto txn2 = txn_manager.BeginTransaction();
std::unique_ptr<executor::ExecutorContext> context(
new executor::ExecutorContext(txn2));
executor::AggregateExecutor executor(&node, context.get());
MockExecutor child_executor;
executor.AddChild(&child_executor);
EXPECT_CALL(child_executor, DInit()).WillOnce(Return(true));
EXPECT_CALL(child_executor, DExecute())
.WillOnce(Return(true))
.WillOnce(Return(true))
.WillOnce(Return(false));
EXPECT_CALL(child_executor, GetOutput())
.WillOnce(Return(source_logical_tile1.release()))
.WillOnce(Return(source_logical_tile2.release()));
EXPECT_TRUE(executor.Init());
EXPECT_TRUE(executor.Execute());
txn_manager.CommitTransaction();
/* Verify result */
std::unique_ptr<executor::LogicalTile> result_tile(executor.GetOutput());
EXPECT_TRUE(result_tile.get() != nullptr);
EXPECT_TRUE(result_tile->GetValue(0, 0)
//.........这里部分代码省略.........
示例12: CEPHFSAL_rename
fsal_status_t CEPHFSAL_rename(fsal_handle_t * extold_parent,
fsal_name_t * old_name,
fsal_handle_t * extnew_parent,
fsal_name_t * new_name,
fsal_op_context_t * extcontext,
fsal_attrib_list_t * src_dir_attributes,
fsal_attrib_list_t * tgt_dir_attributes)
{
int rc;
cephfsal_handle_t* old_parent = (cephfsal_handle_t*) extold_parent;
cephfsal_handle_t* new_parent = (cephfsal_handle_t*) extnew_parent;
cephfsal_op_context_t* context = (cephfsal_op_context_t*) extcontext;
char oldstr[FSAL_MAX_NAME_LEN+1];
char newstr[FSAL_MAX_NAME_LEN+1];
int uid = FSAL_OP_CONTEXT_TO_UID(context);
int gid = FSAL_OP_CONTEXT_TO_GID(context);
/* sanity checks.
* note : src/tgt_dir_attributes are optional.
*/
if(!old_parent || !new_parent || !old_name || !new_name || !context)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_rename);
if(src_dir_attributes)
{
fsal_status_t status =
CEPHFSAL_getattrs(extold_parent, extcontext, src_dir_attributes);
if(FSAL_IS_ERROR(status))
{
FSAL_CLEAR_MASK(src_dir_attributes->asked_attributes);
FSAL_SET_MASK(src_dir_attributes->asked_attributes,
FSAL_ATTR_RDATTR_ERR);
}
}
if(tgt_dir_attributes)
{
fsal_status_t status;
/* optimization when src=tgt : */
if(!CEPHFSAL_handlecmp(extold_parent, extnew_parent, &status)
&& src_dir_attributes)
{
/* If source dir = target dir, we just copy the attributes.
* to avoid doing another getattr.
*/
(*tgt_dir_attributes) = (*src_dir_attributes);
}
else
{
status = CEPHFSAL_getattrs(extnew_parent, extcontext,
tgt_dir_attributes);
if(FSAL_IS_ERROR(status))
{
FSAL_CLEAR_MASK(tgt_dir_attributes->asked_attributes);
FSAL_SET_MASK(tgt_dir_attributes->asked_attributes,
FSAL_ATTR_RDATTR_ERR);
}
}
}
FSAL_name2str(old_name, oldstr, FSAL_MAX_NAME_LEN);
FSAL_name2str(new_name, newstr, FSAL_MAX_NAME_LEN);
rc = ceph_ll_rename(context->export_context->cmount,
VINODE(old_parent), oldstr,
VINODE(new_parent), newstr,
uid, gid);
if (rc < 0)
Return(posix2fsal_error(rc), 0, INDEX_FSAL_rename);
/* OK */
Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_rename);
}
示例13: while
//.........这里部分代码省略.........
for(int i=0; i<data.boxesUnsafe.size();i++) { //process unsafe boxes
IntervalVector currentBox=data.boxesUnsafe.at(i);
IntervalVector nextBox = currentBox.subvector(0, data.numVarF-1);
if (data.intMethod==0){ //Guaranteed integration
// State variables
Variable y(data.numVarF);
// Initial conditions
IntervalVector yinit(data.numVarF);
for (int i = 0; i < data.numVarF; ++i) {
yinit[i] = currentBox[i];
cout<<currentBox[i]<<endl;
}
Interval t = currentBox[data.numVarF];
Interval xd = 7*t;
Interval xdd = 7;
Interval yd = sin(0.1*t);
Interval ydd = 0.1*cos(0.1*t);
// Interval xdiff = (xd-y[0]+xdd);
// Interval ydiff = (yd-y[1]+ydd);
// Interval norm = (sqrt((xdiff)^2 +(ydiff)^2));
// system fn has to be re entered here, cannot be loaded directly from text file
//pendulum
Function ydot = Function (y,Return (y[1],-1*sin(y[0])-0.15*y[1])); // Ivp contruction (initial time is 0.0)
//non holonomic
// Function ydot = Function (y, Return ((sqrt(((xd-y[0]+xdd)*(xd-y[0]+xdd)) +((yd-y[1]+ydd)*(yd-y[1]+ydd))))*cos(y[2]), (sqrt(((xd-y[0]+xdd)*(xd-y[0]+xdd)) +((yd-y[1]+ydd)*(yd-y[1]+ydd))))*sin(y[2]),10*(cos(y[2])*((yd-y[1]+ydd))-sin(y[2])*((xd-y[0]+xdd)))/(sqrt(((xd-y[0]+xdd)*(xd-y[0]+xdd)) +((yd-y[1]+ydd)*(yd-y[1]+ydd)))))); // Ivp contruction (initial time is 0.0)
QTime t1;
t1.start();
ivp_ode problem = ivp_ode (ydot,0.0 , yinit);
// Simulation construction and run
simulation simu = simulation (&problem,data.dt*data.numFuturePos, __METH__, __PREC__); //uses Runge-kutta4 method
data.boxesUnsafeFuture.append(simu.run_simulation()); //modified ibex_simulation.h to make it return a list with all the solutions, not just the last one
double timeSiviaCalculations1=t1.elapsed()/1000.0;
double timeSiviaCalculationsTotal=tSivia.elapsed()/1000.0;
cout<<endl<<"Unsafe # "<<i<<" , Box time = "<<timeSiviaCalculations1<<" , Total elapsed time = "<<timeSiviaCalculationsTotal<<endl;
}
if (data.intMethod==1){ //euler method
for (int i = 0;i<data.numFuturePos;i++){
IntervalVector gdotValue=gdot.eval_vector(currentBox); //evaluate the g and gdot functions to inspect the constraints
IntervalVector gValue=data.g->eval_vector(currentBox);
if (data.myDebug){
cout<<"box = "<<currentBox<<endl;
for(int j = 0; j<gValue.size(); j++){
cout<<"gdot"<<j<<" = "<<gdotValue<<" / "<<(gdotValue[j].lb()>0) <<endl; //gdot i values
示例14: VFSFSAL_rcp
fsal_status_t VFSFSAL_rcp(fsal_handle_t * filehandle, /* IN */
fsal_op_context_t * p_context, /* IN */
fsal_path_t * p_local_path, /* IN */
fsal_rcpflag_t transfer_opt /* IN */
)
{
int local_fd;
int local_flags;
int errsv;
fsal_file_t fs_fd;
fsal_openflags_t fs_flags;
fsal_status_t st = FSAL_STATUS_NO_ERROR;
/* default buffer size for RCP: 10MB */
#define RCP_BUFFER_SIZE 10485760
caddr_t IObuffer;
int to_local = FALSE;
int to_fs = FALSE;
int eof = FALSE;
ssize_t local_size;
fsal_size_t fs_size;
/* sanity checks. */
if(!filehandle || !p_context || !p_local_path)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_rcp);
to_local = ((transfer_opt & FSAL_RCP_FS_TO_LOCAL) == FSAL_RCP_FS_TO_LOCAL);
to_fs = ((transfer_opt & FSAL_RCP_LOCAL_TO_FS) == FSAL_RCP_LOCAL_TO_FS);
if(to_local)
LogFullDebug(COMPONENT_FSAL,
"FSAL_rcp: FSAL -> local file (%s)", p_local_path->path);
if(to_fs)
LogFullDebug(COMPONENT_FSAL,
"FSAL_rcp: local file -> FSAL (%s)", p_local_path->path);
/* must give the sens of transfert (exactly one) */
if((!to_local && !to_fs) || (to_local && to_fs))
Return(ERR_FSAL_INVAL, 0, INDEX_FSAL_rcp);
/* first, open local file with the correct flags */
if(to_fs)
{
local_flags = O_RDONLY;
}
else
{
local_flags = O_WRONLY | O_TRUNC;
if((transfer_opt & FSAL_RCP_LOCAL_CREAT) == FSAL_RCP_LOCAL_CREAT)
local_flags |= O_CREAT;
if((transfer_opt & FSAL_RCP_LOCAL_EXCL) == FSAL_RCP_LOCAL_EXCL)
local_flags |= O_EXCL;
}
if(isFullDebug(COMPONENT_FSAL))
{
char msg[1024];
msg[0] = '\0';
if((local_flags & O_RDONLY) == O_RDONLY)
strcat(msg, "O_RDONLY ");
if((local_flags & O_WRONLY) == O_WRONLY)
strcat(msg, "O_WRONLY ");
if((local_flags & O_TRUNC) == O_TRUNC)
strcat(msg, "O_TRUNC ");
if((local_flags & O_CREAT) == O_CREAT)
strcat(msg, "O_CREAT ");
if((local_flags & O_EXCL) == O_EXCL)
strcat(msg, "O_EXCL ");
LogFullDebug(COMPONENT_FSAL, "Openning local file %s with flags: %s",
p_local_path->path, msg);
}
local_fd = open(p_local_path->path, local_flags);
errsv = errno;
if(local_fd == -1)
{
Return(posix2fsal_error(errsv), errsv, INDEX_FSAL_rcp);
}
//.........这里部分代码省略.........
示例15: LUSTREFSAL_opendir
/**
* FSAL_opendir :
* Opens a directory for reading its content.
*
* \param dir_handle (input)
* the handle of the directory to be opened.
* \param cred (input)
* Permission context for the operation (user,...).
* \param dir_descriptor (output)
* pointer to an allocated structure that will receive
* directory stream informations, on successfull completion.
* \param dir_attributes (optional output)
* On successfull completion,the structure pointed
* by dir_attributes receives the new directory attributes.
* May be NULL.
*
* \return Major error codes :
* - ERR_FSAL_NO_ERROR (no error)
* - Another error code if an error occured.
*/
fsal_status_t LUSTREFSAL_opendir(fsal_handle_t * p_dir_handle, /* IN */
fsal_op_context_t * p_context, /* IN */
fsal_dir_t *dir_desc, /* OUT */
fsal_attrib_list_t * p_dir_attributes /* [ IN/OUT ] */
)
{
int rc;
fsal_status_t status;
fsal_path_t fsalpath;
struct stat buffstat;
lustrefsal_dir_t *p_dir_descriptor = (lustrefsal_dir_t *)dir_desc;
/* sanity checks
* note : dir_attributes is optionnal.
*/
if(!p_dir_handle || !p_context || !p_dir_descriptor)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_opendir);
/* get the path of the directory */
status = fsal_internal_Handle2FidPath(p_context, p_dir_handle, &fsalpath);
if(FSAL_IS_ERROR(status))
ReturnStatus(status, INDEX_FSAL_opendir);
/* get directory metadata */
TakeTokenFSCall();
rc = lstat(fsalpath.path, &buffstat);
ReleaseTokenFSCall();
if(rc != 0)
{
rc = errno;
if(rc == ENOENT)
Return(ERR_FSAL_STALE, rc, INDEX_FSAL_opendir);
else
Return(posix2fsal_error(rc), rc, INDEX_FSAL_opendir);
}
/* Test access rights for this directory */
status = fsal_internal_testAccess(p_context, FSAL_R_OK, &buffstat, NULL);
if(FSAL_IS_ERROR(status))
ReturnStatus(status, INDEX_FSAL_opendir);
/* if everything is OK, fills the dir_desc structure : */
TakeTokenFSCall();
p_dir_descriptor->p_dir = opendir(fsalpath.path);
ReleaseTokenFSCall();
if(!p_dir_descriptor->p_dir)
Return(posix2fsal_error(errno), errno, INDEX_FSAL_opendir);
memcpy(&(p_dir_descriptor->context), p_context, sizeof(lustrefsal_op_context_t));
memcpy(&(p_dir_descriptor->path), &fsalpath, sizeof(fsal_path_t));
memcpy(&(p_dir_descriptor->handle), p_dir_handle, sizeof(lustrefsal_handle_t));
if(p_dir_attributes)
{
status = posix2fsal_attributes(&buffstat, p_dir_attributes);
if(FSAL_IS_ERROR(status))
{
FSAL_CLEAR_MASK(p_dir_attributes->asked_attributes);
FSAL_SET_MASK(p_dir_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR);
}
}
Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_opendir);
}