Esempio n. 1
0
  public static void main(String[] args) throws IOException, OncRpcException, InterruptedException {
    if (args.length < 3) {
      System.err.println("Usage: port doss-nfsd blobstore-path exports-file");
      System.err.println("");
      System.err.println(
          "The exports file is the same format as /etc/exports.  Use / as the path.");
      System.err.println("You can send SIGHUP to reload it without restarting.");
      System.exit(1);
    }

    int port = Integer.parseInt(args[0]);
    String blobStorePath = args[1];
    String exportsFilePath = args[2];

    try (BlobStore blobStore = LocalBlobStore.open(Paths.get(blobStorePath))) {

      // virtual file system
      VirtualFileSystem fs = new BlobStoreVFS(blobStore);

      // exports config file
      ExportFile exports = new ExportFile(new File(exportsFilePath));
      registerSignalHandler(exports);

      // NFS 4 server
      DeviceManager devManager = new DeviceManager();
      MDSOperationFactory opfac = new MDSOperationFactory();
      NFSServerV41 nfs4 = new NFSServerV41(opfac, devManager, fs, exports);
      monkeyPatchSeqidValidation(nfs4);

      // mountd
      MountServer mountd = new MountServer(exports, fs);

      // RPC server
      OncRpcSvc rpcSvc =
          new OncRpcSvcBuilder()
              .withPort(port)
              .withTCP()
              .withAutoPublish()
              .withSameThreadIoStrategy()
              .build();
      Map<OncRpcProgram, RpcDispatchable> services = new HashMap<>();
      rpcSvc.register(new OncRpcProgram(nfs4_prot.NFS4_PROGRAM, nfs4_prot.NFS_V4), nfs4);
      rpcSvc.register(new OncRpcProgram(mount_prot.MOUNT_PROGRAM, mount_prot.MOUNT_V3), mountd);
      // rpcSvc.setPrograms(services);
      rpcSvc.start();

      try {
        // hang around for a while
        while (true) {
          Thread.sleep(100000000);
        }
      } finally {
        rpcSvc.stop();
      }
    }
  }
Esempio n. 2
0
  public void init() throws Exception {

    _cellName = getCellName();
    _domainName = getCellDomainName();

    _rpcService = new OncRpcSvcBuilder().withPort(_port).withTCP().withAutoPublish().build();
    if (_enableRpcsecGss) {
      _rpcService.setGssSessionManager(new GssSessionManager(_idMapper));
    }

    _vfs = new VfsCache(new ChimeraVfs(_fileFileSystemProvider, _idMapper), _vfsCacheConfig);

    MountServer ms = new MountServer(_exportFile, _vfs);
    _rpcService.register(new OncRpcProgram(mount_prot.MOUNT_PROGRAM, mount_prot.MOUNT_V3), ms);
    _rpcService.register(new OncRpcProgram(mount_prot.MOUNT_PROGRAM, mount_prot.MOUNT_V3), ms);

    for (String version : _versions) {
      switch (version) {
        case V3:
          NfsServerV3 nfs3 = new NfsServerV3(_exportFile, _vfs);
          _rpcService.register(new OncRpcProgram(nfs3_prot.NFS_PROGRAM, nfs3_prot.NFS_V3), nfs3);
          break;
        case V41:
          final NFSv41DeviceManager _dm = this;
          _proxyIoFactory =
              new DcapProxyIoFactory(getCellAddress().getCellName() + "-dcap-proxy", "");
          _proxyIoFactory.setBillingStub(_billingStub);
          _proxyIoFactory.setFileSystemProvider(_fileFileSystemProvider);
          _proxyIoFactory.setPnfsHandler(_pnfsHandler);
          _proxyIoFactory.setPoolManager(_poolManagerStub.getDestinationPath());
          _proxyIoFactory.setIoQueue(_ioQueue);
          _proxyIoFactory.setRetryPolicy(RETRY_POLICY);
          _proxyIoFactory.startAdapter();
          _nfs4 =
              new NFSServerV41(
                  new ProxyIoMdsOpFactory(_proxyIoFactory, new MDSOperationFactory()),
                  _dm,
                  _vfs,
                  _idMapper,
                  _exportFile);
          _rpcService.register(new OncRpcProgram(nfs4_prot.NFS4_PROGRAM, nfs4_prot.NFS_V4), _nfs4);
          _loginBrokerHandler.start();
          break;
        default:
          throw new IllegalArgumentException("Unsupported NFS version: " + version);
      }
    }

    _rpcService.start();
  }