public function testGetServerInfo() { $data = $this->getServerInfoData(); $this->serializer->expects($this->never())->method('serialize'); $this->serverInfoResponse->expects($this->exactly(3))->method('getData')->willReturn($data); $this->client->expects($this->once())->method('send')->with($this->isInstanceOf('Elastification\\Client\\Request\\V1x\\NodeInfoRequest'))->willReturn($this->serverInfoResponse); $serverInfo = $this->repository->getServerInfo(self::HOST, self::PORT); $this->assertInstanceOf('Elastification\\BackupRestore\\Entity\\ServerInfo', $serverInfo); $this->assertSame($data['name'], $serverInfo->name); $this->assertSame($data['cluster_name'], $serverInfo->clusterName); $this->assertSame($data['version']['number'], $serverInfo->version); }
/** * Creates a backup job * * @param string $source * @param string $host * @param int $port * @return RestoreJob * @throws \Exception * @author Daniel Wendlandt */ public function createJob($source, $host, $port = 9200) { $restoreJob = new RestoreJob(); $restoreJob->setHost($host); $restoreJob->setPort($port); $restoreJob->setSource(dirname($source)); $restoreJob->setName(basename($source)); $restoreJob->setServerInfo($this->elastic->getServerInfo($host, $port)); $restoreJob->setMappings($this->filesystem->loadMappings($restoreJob->getPath())); if (!VersionHelper::isVersionAllowed($restoreJob->getServerInfo()->version)) { throw new \Exception('Elasticsearch version ' . $restoreJob->getServerInfo()->version . ' is not supported by this tool'); } return $restoreJob; }
/** * Creates a backup job * * @param string $target * @param string $host * @param int $port * @param array $mappings * @return BackupJob * @throws \Exception * @author Daniel Wendlandt */ public function createJob($target, $host, $port = 9200, array $mappings = array()) { $backupJob = new BackupJob(); $backupJob->setHost($host); $backupJob->setPort($port); $backupJob->setTarget($target); $backupJob->setServerInfo($this->elastic->getServerInfo($host, $port)); $backupJob->setMappings($this->elastic->getAllMappings($host, $port)); if (!empty($mappings)) { $backupJob->getMappings()->reduceIndices($mappings); } if (!VersionHelper::isVersionAllowed($backupJob->getServerInfo()->version)) { throw new \Exception('Elasticsearch version ' . $backupJob->getServerInfo()->version . ' is not supported by this tool'); } return $backupJob; }