Loading ...
Sorry, an error occurred while loading the content.

Service name in GDS

Expand Messages
  • Ruslan Cheremin
    Hello, All! Currently I m using JBird to connect Firebird server API. The exactly task I working for is checking, is server is running. For such a thing I was
    Message 1 of 4 , Jul 3, 2009
    • 0 Attachment
      Hello, All!

      Currently I'm using JBird to connect Firebird server API. The exactly task I working
      for is checking, is server is running. For such a thing I was trying just to try to
      connect to "anonymous" Firebird service and see, can it accept connections. Code like
      this (it was adopted from C):
      [code]
      final AbstractGDS gds = ...;

      final String serviceName = "localhost:3050/anonymous";

      final ServiceParameterBuffer spb = gds.createServiceParameterBuffer();
      spb.addArgument(
      ISCConstants.isc_spb_user_name,
      "fake"
      );
      spb.addArgument(
      ISCConstants.isc_spb_password,
      "fake"
      );

      //don't sure do we need it -- all works even if missed
      //spb.addArgument(ISCConstants.isc_spb_dummy_packet_interval,
      //new byte[] { 120, 10, 0, 0 });

      final IscSvcHandle handle = gds.createIscSvcHandle();
      try {
      gds.iscServiceAttach( serviceName, handle, spb );
      gds.iscServiceDetach( handle );
      return true;
      } catch ( GDSException e ) {
      ...
      }
      return false;
      [/code]


      But I've got an error executing this code. Digging source of
      AbstractJavaGDSImpl.iscServiceAttach( service, handle, spb ) I've found, that, although
      there is explicit parameter service, inside method there is explicit check for it to
      be "<host>:<port>/service_mgr" -- serviceName can be "service_mgr" only:
      [code]
      ...
      String serviceMgrStr = "service_mgr";
      int mgrIndex = service.indexOf(serviceMgrStr);
      if (mgrIndex == -1 || mgrIndex + serviceMgrStr.length() != service.length())
      throw new GDSException(ISCConstants.isc_arg_gds, ISCConstants.isc_svcnotdef, service);
      ...
      [/code]

      I suppose, it's some kind of self-check, it seems, inside JBird only "service_mgr" service
      used. But it is not explicit, and not logical for me. If I can suggest, my suggestion will
      be:
      1. gds.iscServiceAttach( serviceName, handle, spb ) does not check for serviceName at all.
      Suppose it to be universal.
      2. create method gds.iscServiceAttach( host, port, handle, spb ), which is mapped to
      gds.iscServiceAttach( String.format("%s:%d/%s", host, port, "service_mgr"), handle, spb )
      -- and this method should be used inside JBird.
      3. I also noticed, that "service_mgr" string constant used at least twice in JBird sources,
      and both time assigned explicitly in method code -- like in example above. I suppose it
      will be better to extract it in some constant field like
      public static final String DEFAULT_SERVICE_NAME = "service_mgr";
      It makes code slightly less misterios :)
    • Roman Rokytskyy
      ... The issue is that nothing except this predefined service_mgr will be accepted by Firebird. But your suggestions are also ok, so if you prepare a patch
      Message 2 of 4 , Jul 3, 2009
      • 0 Attachment
        > I suppose, it's some kind of self-check, it seems, inside JBird only "service_mgr" service
        > used. But it is not explicit, and not logical for me. If I can suggest, my suggestion will
        > be:
        > 1. gds.iscServiceAttach( serviceName, handle, spb ) does not check for serviceName at all.
        > Suppose it to be universal.
        > 2. create method gds.iscServiceAttach( host, port, handle, spb ), which is mapped to
        > gds.iscServiceAttach( String.format("%s:%d/%s", host, port, "service_mgr"), handle, spb )
        > -- and this method should be used inside JBird.
        > 3. I also noticed, that "service_mgr" string constant used at least twice in JBird sources,
        > and both time assigned explicitly in method code -- like in example above. I suppose it
        > will be better to extract it in some constant field like
        > public static final String DEFAULT_SERVICE_NAME = "service_mgr";
        > It makes code slightly less misterios :)

        The issue is that nothing except this predefined "service_mgr" will be
        accepted by Firebird. But your suggestions are also ok, so if you
        prepare a patch against HEAD, I will apply it.

        Roman
      • Ruslan Cheremin
        ... Well, at least anonymous is the name should be accepted by Firebird. I haven t tried by myself (since JBird does not allow me to do so), so can t say for
        Message 3 of 4 , Jul 3, 2009
        • 0 Attachment
          --- In Firebird-Java@yahoogroups.com, Roman Rokytskyy <roman@...> wrote:

          > The issue is that nothing except this predefined "service_mgr" will be
          > accepted by Firebird.
          Well, at least "anonymous" is the name should be accepted by Firebird. I haven't tried by myself (since JBird does not allow me to do so), so can't say for sure, but original code in C used it...

          > But your suggestions are also ok, so if you prepare a patch against
          > HEAD, I will apply it.

          Send you by e-mail
        • Roman Rokytskyy
          ... Hmmm... did not know that. ... Thanks! Will do this in few days. Roman
          Message 4 of 4 , Jul 3, 2009
          • 0 Attachment
            > Well, at least "anonymous" is the name should be accepted by Firebird. I haven't tried by myself (since JBird does not allow me to do so), so can't say for sure, but original code in C used it...

            Hmmm... did not know that.

            >> But your suggestions are also ok, so if you prepare a patch against
            >> HEAD, I will apply it.
            >
            > Send you by e-mail

            Thanks! Will do this in few days.

            Roman
          Your message has been successfully submitted and would be delivered to recipients shortly.